108 lines
4 KiB
Diff
108 lines
4 KiB
Diff
diff --git a/nixos/modules/installer/tools/tools.nix b/nixos/modules/installer/tools/tools.nix
|
|
--- a/nixos/modules/installer/tools/tools.nix
|
|
+++ b/nixos/modules/installer/tools/tools.nix
|
|
@@ -86,7 +86,7 @@ in
|
|
'';
|
|
};
|
|
|
|
- config = {
|
|
+ config = mkIf config.nix.enable {
|
|
|
|
system.nixos-generate-config.configuration = mkDefault ''
|
|
# Edit this configuration file to define what should be installed on
|
|
diff --git a/nixos/modules/services/misc/nix-daemon.nix b/nixos/modules/services/misc/nix-daemon.nix
|
|
--- a/nixos/modules/services/misc/nix-daemon.nix
|
|
+++ b/nixos/modules/services/misc/nix-daemon.nix
|
|
@@ -81,6 +81,14 @@ in
|
|
|
|
nix = {
|
|
|
|
+ enable = mkOption {
|
|
+ type = types.bool;
|
|
+ default = true;
|
|
+ description = ''
|
|
+ If disabled, Nix will not be available on the built NixOS system.
|
|
+ '';
|
|
+ };
|
|
+
|
|
package = mkOption {
|
|
type = types.package;
|
|
default = pkgs.nix;
|
|
@@ -498,7 +506,7 @@ in
|
|
|
|
###### implementation
|
|
|
|
- config = {
|
|
+ config = mkIf cfg.enable {
|
|
|
|
nix.binaryCachePublicKeys = [ "cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=" ];
|
|
nix.binaryCaches = [ "https://cache.nixos.org/" ];
|
|
diff --git a/nixos/modules/services/misc/nix-gc.nix b/nixos/modules/services/misc/nix-gc.nix
|
|
--- a/nixos/modules/services/misc/nix-gc.nix
|
|
+++ b/nixos/modules/services/misc/nix-gc.nix
|
|
@@ -48,7 +48,7 @@ in
|
|
|
|
###### implementation
|
|
|
|
- config = {
|
|
+ config = mkIf config.nix.enable {
|
|
|
|
systemd.services.nix-gc =
|
|
{ description = "Nix Garbage Collector";
|
|
diff --git a/nixos/modules/services/misc/nix-optimise.nix b/nixos/modules/services/misc/nix-optimise.nix
|
|
--- a/nixos/modules/services/misc/nix-optimise.nix
|
|
+++ b/nixos/modules/services/misc/nix-optimise.nix
|
|
@@ -36,7 +36,7 @@ in
|
|
|
|
###### implementation
|
|
|
|
- config = {
|
|
+ config = mkIf config.nix.enable {
|
|
|
|
systemd.services.nix-optimise =
|
|
{ description = "Nix Store Optimiser";
|
|
diff --git a/nixos/modules/system/boot/loader/systemd-boot/systemd-boot-builder.py b/nixos/modules/system/boot/loader/systemd-boot/systemd-boot-builder.py
|
|
--- a/nixos/modules/system/boot/loader/systemd-boot/systemd-boot-builder.py
|
|
+++ b/nixos/modules/system/boot/loader/systemd-boot/systemd-boot-builder.py
|
|
@@ -124,18 +124,19 @@ def mkdir_p(path):
|
|
raise
|
|
|
|
def get_generations(profile=None):
|
|
- gen_list = subprocess.check_output([
|
|
- "@nix@/bin/nix-env",
|
|
- "--list-generations",
|
|
- "-p",
|
|
- "/nix/var/nix/profiles/%s" % ("system-profiles/" + profile if profile else "system"),
|
|
- "--option", "build-users-group", ""],
|
|
- universal_newlines=True)
|
|
- gen_lines = gen_list.split('\n')
|
|
- gen_lines.pop()
|
|
+ generation_dir = "/nix/var/nix/profiles/%s" % ("system-profiles" if profile else "",)
|
|
+ profile_name = profile if profile else "system"
|
|
+ generations = []
|
|
+ for gen_entry in os.scandir(generation_dir):
|
|
+ gen_name = gen_entry.name
|
|
+ if not (gen_name.startswith(profile_name + '-') and gen_name.endswith('-link')):
|
|
+ continue
|
|
+ gen_num = gen_name[len(profile_name+'-'):-len('-link')]
|
|
+ generations.append(int(gen_num))
|
|
+ generations.sort()
|
|
|
|
configurationLimit = @configurationLimit@
|
|
- return [ (profile, int(line.split()[0])) for line in gen_lines ][-configurationLimit:]
|
|
+ return [ (profile, gen_num) for gen_num in sorted(generations) ][-configurationLimit:]
|
|
|
|
def remove_old_entries(gens):
|
|
rex_profile = re.compile("^@efiSysMountPoint@/loader/entries/nixos-(.*)-generation-.*\.conf$")
|
|
diff --git a/nixos/modules/system/boot/loader/systemd-boot/systemd-boot.nix b/nixos/modules/system/boot/loader/systemd-boot/systemd-boot.nix
|
|
--- a/nixos/modules/system/boot/loader/systemd-boot/systemd-boot.nix
|
|
+++ b/nixos/modules/system/boot/loader/systemd-boot/systemd-boot.nix
|
|
@@ -16,8 +16,6 @@ let
|
|
|
|
systemd = config.systemd.package;
|
|
|
|
- nix = config.nix.package.out;
|
|
-
|
|
timeout = if config.boot.loader.timeout != null then config.boot.loader.timeout else "";
|
|
|
|
editor = if cfg.editor then "True" else "False";
|