summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlejandro Soto <alejandro@34project.org>2022-12-27 01:21:34 -0600
committerAlejandro Soto <alejandro@34project.org>2022-12-27 01:21:34 -0600
commitccbd359a8f9089a1e7a9566fdca62e26a2bb447c (patch)
treee248f3a9f848187e80d45baf2bd43ad465733fb0
parent61d433c8e7cc17d5b921329fca9baf7c3d528ade (diff)
flake: enforce nixpkgs-fmt
Diffstat (limited to '')
-rw-r--r--flake.nix81
-rw-r--r--home/environ.nix20
-rw-r--r--home/path.nix86
-rw-r--r--pkgs/default.nix28
-rw-r--r--pkgs/mssql-tools.nix30
-rw-r--r--pkgs/oregano/default.nix34
-rw-r--r--pkgs/rqlite.nix3
-rw-r--r--pkgs/rv8.nix50
-rw-r--r--pkgs/scripts/clip.nix27
-rw-r--r--pkgs/scripts/default.nix2
-rw-r--r--pkgs/st.nix2
-rw-r--r--pkgs/tmux-lift/default.nix4
-rw-r--r--sys/auth.nix3
-rw-r--r--sys/boot.nix105
-rw-r--r--sys/fs/btrfs.nix157
-rw-r--r--sys/fs/default.nix3
-rw-r--r--sys/fs/layout.nix57
-rw-r--r--sys/net.nix3
-rw-r--r--sys/options.nix5
-rw-r--r--sys/users.nix3
-rw-r--r--util/importAll.nix6
21 files changed, 392 insertions, 317 deletions
diff --git a/flake.nix b/flake.nix
index c1538c4..292e2a0 100644
--- a/flake.nix
+++ b/flake.nix
@@ -14,7 +14,8 @@
};
outputs =
- { self, nixpkgs, unstable, home-manager, nur, impermanence, hm-isolation, ... }: let
+ { self, nixpkgs, unstable, home-manager, nur, impermanence, hm-isolation, ... }:
+ let
system = "x86_64-linux";
pkgs = pkgsNoLocal.extend self.overlays.default;
@@ -31,7 +32,9 @@
inherit (util pkgs.lib) importAll;
local = import ./pkgs;
- in with pkgs.lib; {
+ in
+ with pkgs.lib; {
+ formatter.${system} = pkgs.nixpkgs-fmt;
packages.${system} = local pkgs pkgsNoLocal;
overlays.default = final: prev: {
@@ -39,45 +42,51 @@
unstable = (importPkgs unstable).extend self.overlays.default;
};
- nixosConfigurations = let
- hostConfig = host: (makeOverridable nixpkgs.lib.nixosSystem) {
- inherit pkgs system;
+ nixosConfigurations =
+ let
+ hostConfig = host: (makeOverridable nixpkgs.lib.nixosSystem) {
+ inherit pkgs system;
- modules = [
- ./sys
- host
- nixpkgs.nixosModules.notDetected
- impermanence.nixosModule
- ];
- };
- in mapAttrs (_: hostConfig) (importAll { root = ./sys/platform; });
+ modules = [
+ ./sys
+ host
+ nixpkgs.nixosModules.notDetected
+ impermanence.nixosModule
+ ];
+ };
+ in
+ mapAttrs (_: hostConfig) (importAll { root = ./sys/platform; });
- homeConfigurations = let
- registry = { ... }: {
- config.nix.registry = {
- "nixpkgs".flake = nixpkgs;
- "unstable".flake = unstable;
- "nur".flake = nur;
+ homeConfigurations =
+ let
+ registry = { ... }: {
+ config.nix.registry = {
+ "nixpkgs".flake = nixpkgs;
+ "unstable".flake = unstable;
+ "nur".flake = nur;
+ };
};
- };
- home = platform: home-manager.lib.homeManagerConfiguration {
- inherit pkgs;
+ home = platform: home-manager.lib.homeManagerConfiguration {
+ inherit pkgs;
- modules = [
- ./home
- platform
- registry
- hm-isolation.homeManagerModule
- ];
- };
+ modules = [
+ ./home
+ platform
+ registry
+ hm-isolation.homeManagerModule
+ ];
+ };
- platformHome = name: platform: let
- value = home platform;
- in {
- inherit value;
- name = "${value.config.home.username}@${name}";
- };
- in mapAttrs' platformHome (importAll { root = ./home/platform; });
+ platformHome = name: platform:
+ let
+ value = home platform;
+ in
+ {
+ inherit value;
+ name = "${value.config.home.username}@${name}";
+ };
+ in
+ mapAttrs' platformHome (importAll { root = ./home/platform; });
};
}
diff --git a/home/environ.nix b/home/environ.nix
index bdfa5b7..b12093e 100644
--- a/home/environ.nix
+++ b/home/environ.nix
@@ -7,15 +7,17 @@ with lib; {
"d %t/vtmp 0700"
];
- home.file = let
- symlink = path: { source = config.lib.file.mkOutOfStoreSymlink path; };
- #TODO: No sirve, creo que por readline
- devNull = symlink "/dev/null";
- in {
- "vtmp" = symlink "/run/user/1000/vtmp";
- ".units_history" = devNull;
- #TODO: .calc_history
- };
+ home.file =
+ let
+ symlink = path: { source = config.lib.file.mkOutOfStoreSymlink path; };
+ #TODO: No sirve, creo que por readline
+ devNull = symlink "/dev/null";
+ in
+ {
+ "vtmp" = symlink "/run/user/1000/vtmp";
+ ".units_history" = devNull;
+ #TODO: .calc_history
+ };
programs = {
zsh = {
diff --git a/home/path.nix b/home/path.nix
index 5632910..152091d 100644
--- a/home/path.nix
+++ b/home/path.nix
@@ -1,47 +1,49 @@
{ config, lib, pkgs, ... }:
with lib; {
- home.packages = let
- py = pkgs.python39Packages;
- in [
- pkgs.file
- pkgs.killall
- pkgs.man-pages
- pkgs.man-pages-posix
- pkgs.tree
- pkgs.unzip
- pkgs.wget
- pkgs.zip
- ] ++ optionals (!config.home.isolation.active) [
- pkgs.calc
- pkgs.cloc
- pkgs.gcc
- pkgs.gnome.gnome-screenshot
- pkgs.gpicview
- pkgs.gruvbox-dark-icons-gtk
- pkgs.hack-font
- pkgs.i3-gaps
- py.ipython
- pkgs.jq
- pkgs.keepassxc
- pkgs.libreoffice-fresh
- pkgs.mosh
- pkgs.mpv
- pkgs.nmap
- pkgs.libsForQt5.okular
- pkgs.pavucontrol
- py.python
- pkgs.rustup
- pkgs.local.scripts
- pkgs.signal-desktop
- pkgs.socat
- pkgs.local.st
- pkgs.tdesktop
- pkgs.local.tmux-lift
- pkgs.teams
- pkgs.units
- pkgs.xsel
- pkgs.zoom-us
- ];
+ home.packages =
+ let
+ py = pkgs.python39Packages;
+ in
+ [
+ pkgs.file
+ pkgs.killall
+ pkgs.man-pages
+ pkgs.man-pages-posix
+ pkgs.tree
+ pkgs.unzip
+ pkgs.wget
+ pkgs.zip
+ ] ++ optionals (!config.home.isolation.active) [
+ pkgs.calc
+ pkgs.cloc
+ pkgs.gcc
+ pkgs.gnome.gnome-screenshot
+ pkgs.gpicview
+ pkgs.gruvbox-dark-icons-gtk
+ pkgs.hack-font
+ pkgs.i3-gaps
+ py.ipython
+ pkgs.jq
+ pkgs.keepassxc
+ pkgs.libreoffice-fresh
+ pkgs.mosh
+ pkgs.mpv
+ pkgs.nmap
+ pkgs.libsForQt5.okular
+ pkgs.pavucontrol
+ py.python
+ pkgs.rustup
+ pkgs.local.scripts
+ pkgs.signal-desktop
+ pkgs.socat
+ pkgs.local.st
+ pkgs.tdesktop
+ pkgs.local.tmux-lift
+ pkgs.teams
+ pkgs.units
+ pkgs.xsel
+ pkgs.zoom-us
+ ];
nixpkgs.config.allowUnfreePredicate = pkg: elem (getName pkg) [
"anydesk"
diff --git a/pkgs/default.nix b/pkgs/default.nix
index bed50a3..a0fc1c7 100644
--- a/pkgs/default.nix
+++ b/pkgs/default.nix
@@ -1,18 +1,20 @@
-final: prev: let
+final: prev:
+let
inherit (final) callPackage fetchpatch;
-in {
- btclone = callPackage ./btclone {};
- git-aliases = callPackage ./git-aliases.nix {};
- mssql-tools = callPackage ./mssql-tools.nix {};
- oregano = callPackage ./oregano {};
- rqlite = callPackage ./rqlite.nix {};
- rv8 = callPackage ./rv8.nix {};
- scripts = callPackage ./scripts {};
- tmux-lift = callPackage ./tmux-lift {};
-
+in
+{
+ btclone = callPackage ./btclone { };
+ git-aliases = callPackage ./git-aliases.nix { };
+ mssql-tools = callPackage ./mssql-tools.nix { };
+ oregano = callPackage ./oregano { };
+ rqlite = callPackage ./rqlite.nix { };
+ rv8 = callPackage ./rv8.nix { };
+ scripts = callPackage ./scripts { };
+ tmux-lift = callPackage ./tmux-lift { };
+
st = prev.st.override {
- conf = import ./st.nix {};
-
+ conf = import ./st.nix { };
+
patches = [
(fetchpatch {
url = "https://st.suckless.org/patches/clipboard/st-clipboard-0.8.3.diff";
diff --git a/pkgs/mssql-tools.nix b/pkgs/mssql-tools.nix
index a2de629..9213c16 100644
--- a/pkgs/mssql-tools.nix
+++ b/pkgs/mssql-tools.nix
@@ -5,7 +5,8 @@
let
version = "17.9.1.1-1";
ubuntuRelease = "21.10";
-in stdenv.mkDerivation {
+in
+stdenv.mkDerivation {
pname = "mssql-tools";
inherit version;
@@ -13,10 +14,11 @@ in stdenv.mkDerivation {
src =
if stdenv.hostPlatform.system == "x86_64-linux" then
- fetchurl {
- url = "https://packages.microsoft.com/ubuntu/${ubuntuRelease}/prod/pool/main/m/mssql-tools/mssql-tools_${version}_amd64.deb";
- sha256 = "0ya9643assr80yh6g0nd3i6iw819frhbb1m421khwplk9iq793kk";
- }
+ fetchurl
+ {
+ url = "https://packages.microsoft.com/ubuntu/${ubuntuRelease}/prod/pool/main/m/mssql-tools/mssql-tools_${version}_amd64.deb";
+ sha256 = "0ya9643assr80yh6g0nd3i6iw819frhbb1m421khwplk9iq793kk";
+ }
else
throw "mssql-tools is not supported on ${stdenv.hostPlatform.system}";
@@ -32,14 +34,16 @@ in stdenv.mkDerivation {
rm -r $out/opt $out/usr
'';
- postFixup = let
- rpath = lib.makeLibraryPath [ glibc stdenv.cc.cc unixODBC ];
- in ''
- for file in $(find $out/bin -type f); do
- patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" "$file"
- patchelf --set-rpath ${rpath} $file
- done
- '';
+ postFixup =
+ let
+ rpath = lib.makeLibraryPath [ glibc stdenv.cc.cc unixODBC ];
+ in
+ ''
+ for file in $(find $out/bin -type f); do
+ patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" "$file"
+ patchelf --set-rpath ${rpath} $file
+ done
+ '';
meta = with lib; {
license = licenses.unfree;
diff --git a/pkgs/oregano/default.nix b/pkgs/oregano/default.nix
index e85dded..82303f4 100644
--- a/pkgs/oregano/default.nix
+++ b/pkgs/oregano/default.nix
@@ -1,9 +1,23 @@
-{ lib, fetchFromGitHub, glib, goocanvas2, groff
-, gtk3, gtksourceview, intltool, libxml2, perl
-, pkg-config, python, stdenv, wafHook, wrapGAppsHook }:
+{ lib
+, fetchFromGitHub
+, glib
+, goocanvas2
+, groff
+, gtk3
+, gtksourceview
+, intltool
+, libxml2
+, perl
+, pkg-config
+, python
+, stdenv
+, wafHook
+, wrapGAppsHook
+}:
let
version = "0.84.43";
-in stdenv.mkDerivation {
+in
+stdenv.mkDerivation {
pname = "oregano";
inherit version;
@@ -18,7 +32,15 @@ in stdenv.mkDerivation {
patches = [ ./gio-unix.patch ];
buildInputs = [
- intltool glib goocanvas2 groff gtk3 gtksourceview
- libxml2 perl pkg-config python
+ intltool
+ glib
+ goocanvas2
+ groff
+ gtk3
+ gtksourceview
+ libxml2
+ perl
+ pkg-config
+ python
];
}
diff --git a/pkgs/rqlite.nix b/pkgs/rqlite.nix
index a56d288..19d0fa3 100644
--- a/pkgs/rqlite.nix
+++ b/pkgs/rqlite.nix
@@ -1,7 +1,8 @@
{ lib, buildGoModule, fetchFromGitHub }:
let
version = "7.5.0";
-in buildGoModule {
+in
+buildGoModule {
pname = "rqlite";
inherit version;
diff --git a/pkgs/rv8.nix b/pkgs/rv8.nix
index 61cb91f..8527601 100644
--- a/pkgs/rv8.nix
+++ b/pkgs/rv8.nix
@@ -17,30 +17,32 @@ stdenv.mkDerivation {
mkdir -p $out/bin $out/lib
'';
- patches = [ (writeText "rv8-include-limits.patch" ''
- diff --git a/src/gen/gen-cc.cc b/src/gen/gen-cc.cc
- index fd9f948..44c8bf7 100644
- --- a/src/gen/gen-cc.cc
- +++ b/src/gen/gen-cc.cc
- @@ -12,6 +12,7 @@
- #include <deque>
- #include <map>
- #include <set>
- +#include <limits>
+ patches = [
+ (writeText "rv8-include-limits.patch" ''
+ diff --git a/src/gen/gen-cc.cc b/src/gen/gen-cc.cc
+ index fd9f948..44c8bf7 100644
+ --- a/src/gen/gen-cc.cc
+ +++ b/src/gen/gen-cc.cc
+ @@ -12,6 +12,7 @@
+ #include <deque>
+ #include <map>
+ #include <set>
+ +#include <limits>
- #include "util.h"
- #include "cmdline.h"
- diff --git a/src/gen/gen-fpu-test.cc b/src/gen/gen-fpu-test.cc
- index f1b8f84..d0a2f32 100644
- --- a/src/gen/gen-fpu-test.cc
- +++ b/src/gen/gen-fpu-test.cc
- @@ -12,6 +12,7 @@
- #include <deque>
- #include <map>
- #include <set>
- +#include <limits>
+ #include "util.h"
+ #include "cmdline.h"
+ diff --git a/src/gen/gen-fpu-test.cc b/src/gen/gen-fpu-test.cc
+ index f1b8f84..d0a2f32 100644
+ --- a/src/gen/gen-fpu-test.cc
+ +++ b/src/gen/gen-fpu-test.cc
+ @@ -12,6 +12,7 @@
+ #include <deque>
+ #include <map>
+ #include <set>
+ +#include <limits>
- #include "util.h"
- #include "cmdline.h"
- '') ];
+ #include "util.h"
+ #include "cmdline.h"
+ '')
+ ];
}
diff --git a/pkgs/scripts/clip.nix b/pkgs/scripts/clip.nix
index 862d82e..501bb3b 100644
--- a/pkgs/scripts/clip.nix
+++ b/pkgs/scripts/clip.nix
@@ -1,5 +1,12 @@
-{ lib ,writeShellScriptBin, gnome, xclip
-, file, imagemagick, toPDF, ... }:
+{ lib
+, writeShellScriptBin
+, gnome
+, xclip
+, file
+, imagemagick
+, toPDF
+, ...
+}:
with lib; let
name = if toPDF then "clip-pdf" else "clip";
@@ -13,13 +20,15 @@ with lib; let
shift
'';
- copyOut = if toPDF then ''
- ${imagemagick}/bin/convert "$CLIP" "$OUT"
- '' else ''
- ${xclip}/bin/xclip -selection clipboard \
- -t $(${file}/bin/file -b --mime-type $CLIP) <"$CLIP"
- '';
-in writeShellScriptBin name ''
+ copyOut =
+ if toPDF then ''
+ ${imagemagick}/bin/convert "$CLIP" "$OUT"
+ '' else ''
+ ${xclip}/bin/xclip -selection clipboard \
+ -t $(${file}/bin/file -b --mime-type $CLIP) <"$CLIP"
+ '';
+in
+writeShellScriptBin name ''
${pdfCmdline}
OPTIONS=-a
diff --git a/pkgs/scripts/default.nix b/pkgs/scripts/default.nix
index 18900f6..43eae89 100644
--- a/pkgs/scripts/default.nix
+++ b/pkgs/scripts/default.nix
@@ -4,6 +4,6 @@ symlinkJoin {
paths = [
(callPackage ./clip.nix { toPDF = false; })
(callPackage ./clip.nix { toPDF = true; })
- (callPackage ./merge-pdfs.nix {})
+ (callPackage ./merge-pdfs.nix { })
];
}
diff --git a/pkgs/st.nix b/pkgs/st.nix
index a19bcea..117b94c 100644
--- a/pkgs/st.nix
+++ b/pkgs/st.nix
@@ -1,4 +1,4 @@
-{ }:
+{}:
''
/* See LICENSE file for copyright and license details. */
diff --git a/pkgs/tmux-lift/default.nix b/pkgs/tmux-lift/default.nix
index 9d1adf2..e353494 100644
--- a/pkgs/tmux-lift/default.nix
+++ b/pkgs/tmux-lift/default.nix
@@ -5,7 +5,7 @@
src = ./.;
installPhase = ''
- mkdir -p $out/bin
- cp lift unlift $out/bin
+ mkdir -p $out/bin
+ cp lift unlift $out/bin
'';
}
diff --git a/sys/auth.nix b/sys/auth.nix
index e6e156d..e85543e 100644
--- a/sys/auth.nix
+++ b/sys/auth.nix
@@ -1,7 +1,8 @@
{ lib, config, ... }:
with lib; let
cfg = config.local;
-in {
+in
+{
config = {
security.pam = {
oath = {
diff --git a/sys/boot.nix b/sys/boot.nix
index 9e1ef85..5d37b25 100644
--- a/sys/boot.nix
+++ b/sys/boot.nix
@@ -1,7 +1,8 @@
{ lib, config, ... }:
with lib; let
cfg = config.local;
-in {
+in
+{
options.local = with lib.types; {
loader = mkOption {
type = enum [ "grub" "systemd-boot" ];
@@ -40,64 +41,70 @@ in {
};
};
- initrd = let
- crypt = cfg.crypt.toplevel;
- headerPathEscaped = escapeShellArg "/initrd-boot/${crypt.headerFromBoot}";
- in {
- availableKernelModules = cfg.initrdModules;
- supportedFilesystems = [ "vfat" ];
+ initrd =
+ let
+ crypt = cfg.crypt.toplevel;
+ headerPathEscaped = escapeShellArg "/initrd-boot/${crypt.headerFromBoot}";
+ in
+ {
+ availableKernelModules = cfg.initrdModules;
+ supportedFilesystems = [ "vfat" ];
- preDeviceCommands = optionalString (crypt != null) ''
- mkdir -p `dirname ${headerPathEscaped}`
- touch ${headerPathEscaped}
- '';
-
- preLVMCommands = optionalString cfg.portable ''
- sleep 2 #TODO
- '';
+ preDeviceCommands = optionalString (crypt != null) ''
+ mkdir -p `dirname ${headerPathEscaped}`
+ touch ${headerPathEscaped}
+ '';
- postMountCommands = let
- fromRoot = path: escapeShellArg "/mnt-root/${path}";
- auxOpen = aux: ''
- cryptsetup -v open \
- --header ${fromRoot aux.header} \
- --key-file ${fromRoot aux.keyfile} \
- ${aux.device} ${aux.target}
+ preLVMCommands = optionalString cfg.portable ''
+ sleep 2 #TODO
'';
- in concatStringsSep "\n" (map auxOpen cfg.crypt.aux);
- luks.devices = mkIf (crypt != null) {
- "${crypt.target}" = {
- inherit (crypt) device;
- header = "/initrd-boot/${crypt.headerFromBoot}";
- preLVM = false;
+ postMountCommands =
+ let
+ fromRoot = path: escapeShellArg "/mnt-root/${path}";
+ auxOpen = aux: ''
+ cryptsetup -v open \
+ --header ${fromRoot aux.header} \
+ --key-file ${fromRoot aux.keyfile} \
+ ${aux.device} ${aux.target}
+ '';
+ in
+ concatStringsSep "\n" (map auxOpen cfg.crypt.aux);
+
+ luks.devices = mkIf (crypt != null) {
+ "${crypt.target}" = {
+ inherit (crypt) device;
+ header = "/initrd-boot/${crypt.headerFromBoot}";
+ preLVM = false;
- preOpenCommands = ''
- mount -o ro -t vfat ${escapeShellArg cfg.fs.boot.device} /initrd-boot
- '';
+ preOpenCommands = ''
+ mount -o ro -t vfat ${escapeShellArg cfg.fs.boot.device} /initrd-boot
+ '';
- postOpenCommands = ''
- umount /initrd-boot
- '';
+ postOpenCommands = ''
+ umount /initrd-boot
+ '';
+ };
};
- };
- #network = {
- # enable = true;
+ #network = {
+ # enable = true;
- # ssh = {
- # enable = true;
- # port = 2234;
- # };
- #};
- };
+ # ssh = {
+ # enable = true;
+ # port = 2234;
+ # };
+ #};
+ };
};
- hardware.cpu = let
- ucode.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
- in {
- amd = mkIf (cfg.cpuVendor == "amd") ucode;
- intel = mkIf (cfg.cpuVendor == "intel") ucode;
- };
+ hardware.cpu =
+ let
+ ucode.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
+ in
+ {
+ amd = mkIf (cfg.cpuVendor == "amd") ucode;
+ intel = mkIf (cfg.cpuVendor == "intel") ucode;
+ };
};
}
diff --git a/sys/fs/btrfs.nix b/sys/fs/btrfs.nix
index 87c9fca..809d35e 100644
--- a/sys/fs/btrfs.nix
+++ b/sys/fs/btrfs.nix
@@ -1,15 +1,16 @@
{ lib, config, pkgs, ... }:
with lib; let
cfg = config.local;
-in {
+in
+{
options.local = with lib.types; {
snapperSubvols = mkOption {
type = attrsOf str;
- default = {};
+ default = { };
};
fs.btrfs = mkOption {
- default = [];
+ default = [ ];
type = attrsOf (submodule {
options = {
@@ -35,77 +36,83 @@ in {
};
config = {
- environment.systemPackages = optional (cfg.snapperSubvols != {}) pkgs.local.btclone;
-
- fileSystems = let
- inherit (cfg) fs;
- btrfs = { device, subvol, ssd, ... }: {
- inherit device;
- fsType = "btrfs";
- options = [ "noatime" "compress=zstd" "subvol=${subvol}" ] ++ optional ssd "ssd";
- };
- in mapAttrs (_: btrfs) cfg.fs.btrfs;
-
- local.snapperSubvols = let
- snapperEntry = path: opts: { name = opts.snapper; value = path; };
- validEntry = _: opts: opts.snapper != null;
- in mapAttrs' snapperEntry (filterAttrs validEntry cfg.fs.btrfs);
-
- services.snapper.configs = let
- snapperConfig = _: subvolume: {
- inherit subvolume;
-
- extraConfig = ''
- # btrfs qgroup for space aware cleanup algorithms
- QGROUP=""
-
- # fraction of the filesystems space the snapshots may use
- SPACE_LIMIT="0.5"
-
- # fraction of the filesystems space that should be free
- FREE_LIMIT="0.2"
-
- # users and groups allowed to work with config
- ALLOW_USERS=""
- ALLOW_GROUPS=""
-
- # sync users and groups from ALLOW_USERS and ALLOW_GROUPS to .snapshots
- # directory
- SYNC_ACL="no"
-
- # start comparing pre- and post-snapshot in background after creating
- # post-snapshot
- BACKGROUND_COMPARISON="yes"
-
- # run daily number cleanup
- NUMBER_CLEANUP="yes"
-
- # limit for number cleanup
- NUMBER_MIN_AGE="1800"
- NUMBER_LIMIT="100"
- NUMBER_LIMIT_IMPORTANT="10"
-
- # create hourly snapshots
- TIMELINE_CREATE="yes"
-
- # cleanup hourly snapshots after some time
- TIMELINE_CLEANUP="yes"
-
- # limits for timeline cleanup
- TIMELINE_MIN_AGE="1800"
- TIMELINE_LIMIT_HOURLY="24"
- TIMELINE_LIMIT_DAILY="7"
- TIMELINE_LIMIT_WEEKLY="4"
- TIMELINE_LIMIT_MONTHLY="12"
- TIMELINE_LIMIT_YEARLY="10"
-
- # cleanup empty pre-post-pairs
- EMPTY_PRE_POST_CLEANUP="yes"
-
- # limits for empty pre-post-pair cleanup
- EMPTY_PRE_POST_MIN_AGE="1800"
- '';
- };
- in mapAttrs snapperConfig cfg.snapperSubvols;
+ environment.systemPackages = optional (cfg.snapperSubvols != { }) pkgs.local.btclone;
+
+ fileSystems =
+ let
+ inherit (cfg) fs;
+ btrfs = { device, subvol, ssd, ... }: {
+ inherit device;
+ fsType = "btrfs";
+ options = [ "noatime" "compress=zstd" "subvol=${subvol}" ] ++ optional ssd "ssd";
+ };
+ in
+ mapAttrs (_: btrfs) cfg.fs.btrfs;
+
+ local.snapperSubvols =
+ let
+ snapperEntry = path: opts: { name = opts.snapper; value = path; };
+ validEntry = _: opts: opts.snapper != null;
+ in
+ mapAttrs' snapperEntry (filterAttrs validEntry cfg.fs.btrfs);
+
+ services.snapper.configs =
+ let
+ snapperConfig = _: subvolume: {
+ inherit subvolume;
+
+ extraConfig = ''
+ # btrfs qgroup for space aware cleanup algorithms
+ QGROUP=""
+
+ # fraction of the filesystems space the snapshots may use
+ SPACE_LIMIT="0.5"
+
+ # fraction of the filesystems space that should be free
+ FREE_LIMIT="0.2"
+
+ # users and groups allowed to work with config
+ ALLOW_USERS=""
+ ALLOW_GROUPS=""
+
+ # sync users and groups from ALLOW_USERS and ALLOW_GROUPS to .snapshots
+ # directory
+ SYNC_ACL="no"
+
+ # start comparing pre- and post-snapshot in background after creating
+ # post-snapshot
+ BACKGROUND_COMPARISON="yes"
+
+ # run daily number cleanup
+ NUMBER_CLEANUP="yes"
+
+ # limit for number cleanup
+ NUMBER_MIN_AGE="1800"
+ NUMBER_LIMIT="100"
+ NUMBER_LIMIT_IMPORTANT="10"
+
+ # create hourly snapshots
+ TIMELINE_CREATE="yes"
+
+ # cleanup hourly snapshots after some time
+ TIMELINE_CLEANUP="yes"
+
+ # limits for timeline cleanup
+ TIMELINE_MIN_AGE="1800"
+ TIMELINE_LIMIT_HOURLY="24"
+ TIMELINE_LIMIT_DAILY="7"
+ TIMELINE_LIMIT_WEEKLY="4"
+ TIMELINE_LIMIT_MONTHLY="12"
+ TIMELINE_LIMIT_YEARLY="10"
+
+ # cleanup empty pre-post-pairs
+ EMPTY_PRE_POST_CLEANUP="yes"
+
+ # limits for empty pre-post-pair cleanup
+ EMPTY_PRE_POST_MIN_AGE="1800"
+ '';
+ };
+ in
+ mapAttrs snapperConfig cfg.snapperSubvols;
};
}
diff --git a/sys/fs/default.nix b/sys/fs/default.nix
index d24e357..04b8acb 100644
--- a/sys/fs/default.nix
+++ b/sys/fs/default.nix
@@ -1,7 +1,8 @@
{ lib, config, ... }:
with lib; let
cfg = config.local.fs;
-in {
+in
+{
imports = [ ./btrfs.nix ./layout.nix ];
options.local.fs = with lib.types; {
diff --git a/sys/fs/layout.nix b/sys/fs/layout.nix
index 897cffe..7e1ac2e 100644
--- a/sys/fs/layout.nix
+++ b/sys/fs/layout.nix
@@ -1,7 +1,8 @@
{ lib, config, ... }:
with lib; let
cfg = config.local;
-in {
+in
+{
options.local.fs.layout = with lib.types; {
sysHddBtrfs = mkOption {
default = null;
@@ -41,38 +42,40 @@ in {
};
config = {
- local.fs.btrfs = let
- sysHddBtrfs = layout: {
- "/" = {
- inherit (layout.sys) device ssd;
- subvol = layout.sys.root;
- };
+ local.fs.btrfs =
+ let
+ sysHddBtrfs = layout: {
+ "/" = {
+ inherit (layout.sys) device ssd;
+ subvol = layout.sys.root;
+ };
- "/toplevel" = {
- inherit (layout.sys) device ssd;
- subvol = layout.sys.toplevel;
- };
+ "/toplevel" = {
+ inherit (layout.sys) device ssd;
+ subvol = layout.sys.toplevel;
+ };
- "/hdd" = {
- inherit (layout.hdd) device;
- subvol = "/";
- ssd = false;
- };
+ "/hdd" = {
+ inherit (layout.hdd) device;
+ subvol = "/";
+ ssd = false;
+ };
- "/home" = {
- inherit (layout.hdd) device;
- subvol = layout.hdd.home;
- ssd = false;
- snapper = "home";
+ "/home" = {
+ inherit (layout.hdd) device;
+ subvol = layout.hdd.home;
+ ssd = false;
+ snapper = "home";
+ };
};
- };
- inherit (cfg.fs) layout;
+ inherit (cfg.fs) layout;
- layoutMaps = [ sysHddBtrfs ];
- layoutOpts = [ layout.sysHddBtrfs ];
- valid = filter ({ snd, ... }: snd != null) (zipLists layoutMaps layoutOpts);
- in optionalAttrs (valid != []) ((head valid).fst (head valid).snd);
+ layoutMaps = [ sysHddBtrfs ];
+ layoutOpts = [ layout.sysHddBtrfs ];
+ valid = filter ({ snd, ... }: snd != null) (zipLists layoutMaps layoutOpts);
+ in
+ optionalAttrs (valid != [ ]) ((head valid).fst (head valid).snd);
assertions = [
{
diff --git a/sys/net.nix b/sys/net.nix
index 30675e0..4075a12 100644
--- a/sys/net.nix
+++ b/sys/net.nix
@@ -1,7 +1,8 @@
{ lib, config, pkgs, ... }:
with lib; let
cfg = config.local;
-in {
+in
+{
options.local = with lib.types; {
hostname = mkOption {
type = str;
diff --git a/sys/options.nix b/sys/options.nix
index f719522..cfb2827 100644
--- a/sys/options.nix
+++ b/sys/options.nix
@@ -1,7 +1,8 @@
{ lib, ... }:
with lib.types; let
inherit (lib) mkOption;
-in {
+in
+{
options.local = {
portable = mkOption {
type = bool;
@@ -29,7 +30,7 @@ in {
};
aux = mkOption {
- default = [];
+ default = [ ];
type = listOf (submodule {
options = {
device = mkOption {
diff --git a/sys/users.nix b/sys/users.nix
index 8c8be6b..d446276 100644
--- a/sys/users.nix
+++ b/sys/users.nix
@@ -1,7 +1,8 @@
{ lib, config, pkgs, ... }:
with lib; let
cfg = config.local;
-in {
+in
+{
config = {
sound.enable = true;
hardware.pulseaudio.enable = true;
diff --git a/util/importAll.nix b/util/importAll.nix
index 678cf06..cc18640 100644
--- a/util/importAll.nix
+++ b/util/importAll.nix
@@ -1,5 +1,5 @@
lib:
-{ root, exclude ? [] }:
+{ root, exclude ? [ ] }:
with builtins; with lib;
# http://chriswarbo.net/projects/nixos/useful_hacks.html
@@ -7,11 +7,11 @@ let
basename = removeSuffix ".nix";
isMatch = name: type: (hasSuffix ".nix" name || type == "directory")
- && ! elem name (map basename exclude);
+ && ! elem name (map basename exclude);
entry = name: _: {
name = basename name;
value = import (root + "/${name}");
};
in
- mapAttrs' entry (filterAttrs isMatch (readDir root))
+mapAttrs' entry (filterAttrs isMatch (readDir root))