From 1b4d91c67b1b4586e4ae205c252d13d545fe31ed Mon Sep 17 00:00:00 2001 From: Gabriel Arazas Date: Sat, 27 Jan 2024 16:51:10 +0800 Subject: [PATCH] modules: create dedicated default Nix config profile --- configs/flake-parts/default.nix | 38 +++++++--------------- configs/flake-parts/home-manager.nix | 1 + configs/flake-parts/nixos.nix | 14 +------- modules/home-manager/profiles/nix-conf.nix | 30 +++++++++++++++++ modules/nixos/profiles/nix-conf.nix | 30 +++++++++++++++++ 5 files changed, 73 insertions(+), 40 deletions(-) create mode 100644 modules/home-manager/profiles/nix-conf.nix create mode 100644 modules/nixos/profiles/nix-conf.nix diff --git a/configs/flake-parts/default.nix b/configs/flake-parts/default.nix index 7ad82510..14fd1a4b 100644 --- a/configs/flake-parts/default.nix +++ b/configs/flake-parts/default.nix @@ -25,33 +25,17 @@ lib.nameValuePair name' { inherit flake; }) inputs; - # Set the package for generating the configuration. - nix.package = lib.mkDefault pkgs.nixStable; - - # Set the configurations for the package manager. - nix.settings = { - # Set several binary caches. - substituters = [ - "https://nix-community.cachix.org" - "https://foo-dogsquared.cachix.org" - ]; - trusted-public-keys = [ - "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=" - "foo-dogsquared.cachix.org-1:/2fmqn/gLGvCs5EDeQmqwtus02TUmGy0ZlAEXqRE70E=" - ]; - - # Sane config for the package manager. - # TODO: Remove this after nix-command and flakes has been considered - # stable. - # - # Since we're using flakes to make this possible, we need it. Plus, the - # UX of Nix CLI is becoming closer to Guix's which is a nice bonus. - experimental-features = [ "nix-command" "flakes" "repl-flake" ]; - auto-optimise-store = lib.mkDefault true; - }; - - # Stallman-senpai will be disappointed. - nixpkgs.config.allowUnfree = true; + nix.settings.nix-path = + (lib.mapAttrsToList + (name: source: + let + name' = if (name == "self") then "config" else name; + in + "${name'}=${source}") + inputs + ++ [ + "/nix/var/nix/profiles/per-user/root/channels" + ]); # Extend nixpkgs with our overlays except for the NixOS-focused modules # here. diff --git a/configs/flake-parts/home-manager.nix b/configs/flake-parts/home-manager.nix index 1e7bbb2a..0590abdc 100644 --- a/configs/flake-parts/home-manager.nix +++ b/configs/flake-parts/home-manager.nix @@ -69,6 +69,7 @@ standaloneConfigModules = [ defaultNixConf + ../../modules/home-manager/profiles/nix-conf.nix ({ config, lib, ... }: { # Don't create the user directories since they are assumed to diff --git a/configs/flake-parts/nixos.nix b/configs/flake-parts/nixos.nix index 3883f073..58e61928 100644 --- a/configs/flake-parts/nixos.nix +++ b/configs/flake-parts/nixos.nix @@ -93,23 +93,11 @@ # Bring our own teeny-tiny snippets of configurations. defaultNixConf ../../modules/nixos/profiles/generic.nix + ../../modules/nixos/profiles/nix-conf.nix # The NixOS module that came from flake-parts. ({ config, lib, ... }: { _module.args = defaultExtraArgs; - - # Set several paths for the traditional channels. - nix.nixPath = lib.mkIf config.nix.channel.enable - (lib.mapAttrsToList - (name: source: - let - name' = if (name == "self") then "config" else name; - in - "${name'}=${source}") - inputs - ++ [ - "/nix/var/nix/profiles/per-user/root/channels" - ]); }) ]; }; diff --git a/modules/home-manager/profiles/nix-conf.nix b/modules/home-manager/profiles/nix-conf.nix new file mode 100644 index 00000000..6792ea63 --- /dev/null +++ b/modules/home-manager/profiles/nix-conf.nix @@ -0,0 +1,30 @@ +{ lib, pkgs, ... }: { + + # Set the package for generating the configuration. + nix.package = lib.mkDefault pkgs.nixStable; + + # Set the configurations for the package manager. + nix.settings = { + # Set several binary caches. + substituters = [ + "https://nix-community.cachix.org" + "https://foo-dogsquared.cachix.org" + ]; + trusted-public-keys = [ + "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=" + "foo-dogsquared.cachix.org-1:/2fmqn/gLGvCs5EDeQmqwtus02TUmGy0ZlAEXqRE70E=" + ]; + + # Sane config for the package manager. + # TODO: Remove this after nix-command and flakes has been considered + # stable. + # + # Since we're using flakes to make this possible, we need it. Plus, the + # UX of Nix CLI is becoming closer to Guix's which is a nice bonus. + experimental-features = [ "nix-command" "flakes" "repl-flake" ]; + auto-optimise-store = lib.mkDefault true; + }; + + # Stallman-senpai will be disappointed. + nixpkgs.config.allowUnfree = true; +} diff --git a/modules/nixos/profiles/nix-conf.nix b/modules/nixos/profiles/nix-conf.nix new file mode 100644 index 00000000..6792ea63 --- /dev/null +++ b/modules/nixos/profiles/nix-conf.nix @@ -0,0 +1,30 @@ +{ lib, pkgs, ... }: { + + # Set the package for generating the configuration. + nix.package = lib.mkDefault pkgs.nixStable; + + # Set the configurations for the package manager. + nix.settings = { + # Set several binary caches. + substituters = [ + "https://nix-community.cachix.org" + "https://foo-dogsquared.cachix.org" + ]; + trusted-public-keys = [ + "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=" + "foo-dogsquared.cachix.org-1:/2fmqn/gLGvCs5EDeQmqwtus02TUmGy0ZlAEXqRE70E=" + ]; + + # Sane config for the package manager. + # TODO: Remove this after nix-command and flakes has been considered + # stable. + # + # Since we're using flakes to make this possible, we need it. Plus, the + # UX of Nix CLI is becoming closer to Guix's which is a nice bonus. + experimental-features = [ "nix-command" "flakes" "repl-flake" ]; + auto-optimise-store = lib.mkDefault true; + }; + + # Stallman-senpai will be disappointed. + nixpkgs.config.allowUnfree = true; +}