From c76e81a086aa66394b37d3bf36592328da09a298 Mon Sep 17 00:00:00 2001 From: Azat Bahawi Date: Fri, 9 Aug 2024 13:06:55 +0300 Subject: 2024-08-09 --- modules/common/nix.nix | 147 +++++++++++++++++++++++++------------------------ 1 file changed, 76 insertions(+), 71 deletions(-) (limited to 'modules/common') diff --git a/modules/common/nix.nix b/modules/common/nix.nix index 01b3f01..efd06bd 100644 --- a/modules/common/nix.nix +++ b/modules/common/nix.nix @@ -22,93 +22,98 @@ in default = [ ]; }; - config = - let + config = { + _module.args = { pkgsLocal = packages.useNixpkgs "${config.my.home}/src/nixpkgs"; # Impure! - in - { - _module.args = { - inherit pkgsLocal; - }; - - hm = { - # Used primarily in conjunction with the "nixfiles" script. - home.file.".nix-defexpr/default.nix".text = - let - hostname = strings.escapeNixIdentifier this.hostname; - in - optionalString this.isHeadful '' - let - self = builtins.getFlake "nixfiles"; - configurations = self.nixosConfigurations; - local = configurations.${hostname}; - in rec { - inherit self; - inherit (self) inputs lib; - inherit (lib) my; - this = my.configurations.${hostname}; - inherit (local) config; - inherit (local.config.system.build) toplevel vm vmWithBootLoader manual; - pretty = expr: lib.trace (lib.generators.toPretty {} expr) {}; - } // configurations // local._module.args - ''; - - programs.bash.shellAliases.nix = "nix --verbose --print-build-logs"; - }; + }; - nix = + hm = { + # Used primarily in conjunction with the "nixfiles" script. + home.file.".nix-defexpr/default.nix".text = let - notSelfInputs = filterAttrs (n: _: n != "self") inputs; + hostname = strings.escapeNixIdentifier this.hostname; in - { - nixPath = mapAttrsToList (n: v: "${n}=${v}") notSelfInputs ++ [ - "nixfiles=${config.my.home}/src/nixfiles" - ]; + optionalString this.isHeadful '' + let + self = builtins.getFlake "nixfiles"; + configurations = self.nixosConfigurations; + local = configurations.${hostname}; + in rec { + inherit self; + inherit (self) inputs lib; + inherit (lib) my; + this = my.configurations.${hostname}; + inherit (local) config; + inherit (local.config.system.build) toplevel vm vmWithBootLoader manual; + pretty = expr: lib.trace (lib.generators.toPretty {} expr) {}; + } // configurations // local._module.args + ''; - registry = mapAttrs (_: flake: { inherit flake; }) notSelfInputs // { - nixfiles.flake = inputs.self; - }; + programs.bash.shellAliases.nix = "nix --verbose --print-build-logs"; + }; - settings = { - warn-dirty = false; + nix = + let + notSelfInputs = filterAttrs (n: _: n != "self") inputs; + in + { + nixPath = mapAttrsToList (n: v: "${n}=${v}") notSelfInputs ++ [ + "nixfiles=${config.my.home}/src/nixfiles" + ]; - keep-going = true; + registry = mapAttrs (_: flake: { inherit flake; }) notSelfInputs // { + nixfiles.flake = inputs.self; + }; - substituters = [ - "https://azahi.cachix.org" - "https://nix-community.cachix.org" - ]; + settings = { + warn-dirty = false; - trusted-substituters = [ "https://azahi.cachix.org" ]; - trusted-public-keys = [ "azahi.cachix.org-1:2bayb+iWYMAVw3ZdEpVg+NPOHCXncw7WMQ0ElX1GO3s=" ]; + keep-going = true; - trusted-users = [ - "root" - my.username - ]; - }; - }; + substituters = [ + "https://azahi.cachix.org" + "https://nix-community.cachix.org" + ]; - nixpkgs = { - config.allowUnfreePredicate = p: elem (getName p) cfg.allowedUnfreePackages; + trusted-substituters = [ "https://azahi.cachix.org" ]; + trusted-public-keys = [ "azahi.cachix.org-1:2bayb+iWYMAVw3ZdEpVg+NPOHCXncw7WMQ0ElX1GO3s=" ]; - overlays = [ inputs.self.overlays.default ]; - }; + trusted-users = [ + "root" + my.username + ]; - environment = { - defaultPackages = [ ]; - systemPackages = - with pkgs; - optionals this.isHeadful [ - nix-tree - nixfiles + experimental-features = mkForce [ + "auto-allocate-uids" + "cgroups" + "fetch-closure" + "flakes" + "nix-command" + "recursive-nix" ]; - variables = { - NIXFILES = optionalString this.isHeadful "${config.my.home}/src/nixfiles"; - NIX_SHELL_PRESERVE_PROMPT = "1"; }; }; - system.stateVersion = this.stateVersion or trivial.release; + nixpkgs = { + config.allowUnfreePredicate = p: elem (getName p) cfg.allowedUnfreePackages; + + overlays = [ inputs.self.overlays.default ]; }; + + environment = { + defaultPackages = [ ]; + systemPackages = + with pkgs; + optionals this.isHeadful [ + nix-tree + nixfiles + ]; + variables = { + NIXFILES = optionalString this.isHeadful "${config.my.home}/src/nixfiles"; + NIX_SHELL_PRESERVE_PROMPT = "1"; + }; + }; + + system.stateVersion = this.stateVersion or trivial.release; + }; } -- cgit v1.2.3