diff --git a/home/home.nix b/home/home.nix index a7ee264..69afdf8 100644 --- a/home/home.nix +++ b/home/home.nix @@ -1,9 +1,7 @@ { lib, ... }: -with lib; - let - importAll = imports: foldl' concat [ ] (map import imports); + importAll = imports: lib.foldl' lib.concat [ ] (map import imports); in { imports = importAll [ diff --git a/home/modules/cli/starship.nix b/home/modules/cli/starship.nix index 02c9011..fead1ad 100644 --- a/home/modules/cli/starship.nix +++ b/home/modules/cli/starship.nix @@ -1,12 +1,9 @@ { pkgs, lib, myLib, ... }: -with builtins; -with lib; -with myLib; let - isRust = path: hasSuffix ".rs" path && path != "mod.rs"; - toogleModules = enabled: modules: mergeAll (map (mod: { "${mod}" = { disabled = !enabled; }; }) modules); + isRust = path: lib.hasSuffix ".rs" path && path != "mod.rs"; + toogleModules = enabled: modules: myLib.mergeAll (map (mod: { "${mod}" = { disabled = !enabled; }; }) modules); starshipPackage = pkgs.unstable.starship; promptOrder = [ "nix_shell" @@ -26,7 +23,7 @@ let "line_break" "character" ]; - promptFormat = concatStrings (map (s: "\$${s}") promptOrder); + promptFormat = lib.concatStrings (map (s: "\$${s}") promptOrder); modulesSources = "${starshipPackage.src}/src/modules"; enabledModules = toogleModules true promptOrder; # <== ensure all modules used in the prompt are enabled @@ -35,10 +32,10 @@ let # - List all Rust sources files # - Get the file name, without the extension (<- name of the module) # - Exclude the enabled modules - disabledModules = pipe modulesSources [ - (filterFiles isRust) - (map (removeSuffix ".rs")) - (subtractLists promptOrder) + disabledModules = lib.pipe modulesSources [ + (myLib.filterFiles isRust) + (map (lib.removeSuffix ".rs")) + (lib.subtractLists promptOrder) (toogleModules false) ]; starshipConfig = { @@ -85,7 +82,7 @@ in enableZshIntegration = true; catppuccin.enable = true; package = starshipPackage; - settings = mergeAll [ + settings = myLib.mergeAll [ enabledModules disabledModules starshipConfig diff --git a/home/modules/wm/xmonad.nix b/home/modules/wm/xmonad.nix index d9d1cef..e392679 100644 --- a/home/modules/wm/xmonad.nix +++ b/home/modules/wm/xmonad.nix @@ -1,14 +1,11 @@ { pkgs, config, lib, myLib, ... }: -with lib; -with myLib; - let libPath = ./xmonad-config/lib; - libFiles = pipe libPath [ - listFiles + libFiles = lib.pipe libPath [ + myLib.listFiles (map (file: { "${file}" = libPath + "/${file}"; })) - mergeAll + myLib.mergeAll ]; in { diff --git a/lib/dev-shell.nix b/lib/dev-shell.nix index 418f58a..0bce2bb 100644 --- a/lib/dev-shell.nix +++ b/lib/dev-shell.nix @@ -1,10 +1,8 @@ { pkgs, lintingPkgs, agenixBin }: -with pkgs; - let - agenixFile = writeShellScriptBin "agenix-file" "cat $2 | ${agenixBin}/bin/agenix --editor='-' -e $1"; - nixTools = [ + agenixFile = pkgs.writeShellScriptBin "agenix-file" "cat $2 | ${agenixBin}/bin/agenix --editor='-' -e $1"; + nixTools = with pkgs; [ cachix git-secret nixpkgs-fmt @@ -12,13 +10,13 @@ let agenixBin agenixFile ]; - haskellTools = with haskellPackages; [ + haskellTools = with pkgs.haskellPackages; [ cabal-install fourmolu haskell-language-server hlint ]; - xmonadDependencies = [ + xmonadDependencies = with pkgs; [ xorg.libX11 xorg.libXrandr xorg.libXScrnSaver @@ -28,7 +26,7 @@ let zlib.dev ]; in -mkShell { +pkgs.mkShell { name = "nix-config-dev"; buildInputs = diff --git a/modules/common/profile.nix b/modules/common/profile.nix index f7b7ac2..a67eea1 100644 --- a/modules/common/profile.nix +++ b/modules/common/profile.nix @@ -1,9 +1,7 @@ { config, lib, ... }: -with lib; - { - options.profile = with types; mkOption { + options.profile = with lib; with types; mkOption { description = "Usage profile for this machine. Must be set."; default = null; type = nullOr (enum [ diff --git a/modules/nixos/illuminanced.nix b/modules/nixos/illuminanced.nix index 18145c4..e6b831a 100644 --- a/modules/nixos/illuminanced.nix +++ b/modules/nixos/illuminanced.nix @@ -1,8 +1,5 @@ { config, lib, myLib, pkgs, ... }: -with lib; -with myLib; - let pidFile = "/var/run/illuminanced.pid"; cfg = config.services.illuminanced; @@ -19,7 +16,7 @@ let hash = "sha256-PQHGKz/2UxCf8FosuxmL7DL9Z+H9nzXHdyn+73gWw1I="; }; }; - levels = mergeAll (lists.imap0 + levels = myLib.mergeAll (lib.lists.imap0 (i: v: { "illuminance_${toString i}" = v.illuminance; "light_${toString i}" = v.light; @@ -56,7 +53,7 @@ in # TODO: document module options # - kalman # - devices.events - options.services.illuminanced = with types; { + options.services.illuminanced = with lib; with types; { enable = mkEnableOption "Enable illuminanced"; package = mkOption { type = package; @@ -160,7 +157,7 @@ in }; }; - config = mkIf cfg.enable { + config = lib.mkIf cfg.enable { systemd.services.illuminanced = { enable = true; wantedBy = [ "multi-user.target" ]; diff --git a/modules/nixos/impermanence.nix b/modules/nixos/impermanence.nix index 10ebb79..1ce53bb 100644 --- a/modules/nixos/impermanence.nix +++ b/modules/nixos/impermanence.nix @@ -1,8 +1,5 @@ { config, lib, myLib, ... }: -with lib; -with myLib; - let cfg = config.system.impermanence; concat = s1: s2: s1 + s2; @@ -25,7 +22,7 @@ let } // options; in { - options.system.impermanence = with types; { + options.system.impermanence = with lib; with types; { enable = mkEnableOption "Enable impermanence"; pause = mkEnableOption "Keep disk layout, but do not wipe on boot"; @@ -110,9 +107,9 @@ in }; }; - config = mkMerge [ + config = lib.mkMerge [ # Generic support: setting paths, enable fuse, etc... - (mkIf cfg.enable { + (lib.mkIf cfg.enable { ########## # SYSTEM # @@ -125,10 +122,10 @@ in environment.persistence.${cfg.paths.homes} = { hideMounts = true; - users = pipe cfg.users [ - attrValues + users = lib.pipe cfg.users [ + lib.attrValues (map perUser) - mergeAll + myLib.mergeAll ]; }; }) @@ -136,12 +133,12 @@ in # - blank snapshot after creation # - auto restore blank snapshot at boot # - Create datasets for system, homes and the nix store - (mkIf (cfg.enable && cfg.zfs.enable) { + (lib.mkIf (cfg.enable && cfg.zfs.enable) { boot = { loader.grub.zfsSupport = true; supportedFilesystems = [ "zfs" ]; - initrd.postDeviceCommands = mkAfter ( - mkIfElse (!cfg.pause) + initrd.postDeviceCommands = lib.mkAfter ( + myLib.mkIfElse (!cfg.pause) "zfs rollback -r ${blankSnapshot cfg.zfs.pool} && echo 'Blank snapshot restored'" "" ); diff --git a/system/users.nix b/system/users.nix index e6fb0fd..7cff537 100644 --- a/system/users.nix +++ b/system/users.nix @@ -1,8 +1,7 @@ { pkgs, config, myLib, agenix, catppuccin, ... }: -with myLib; let - networkManager = mkIfElse + networkManager = myLib.mkIfElse config.networking.networkmanager.enable [ "networkmanager" ] [ ];