Skip to content

Commit

Permalink
Disable nix tooling
Browse files Browse the repository at this point in the history
- Disable nix tooling if development setup is not enabled
- Indirectly disables nix tooling in release build
- Enable automatic garbaze collection in ghaf-host only

Signed-off-by: Ganga Ram <[email protected]>
  • Loading branch information
gngram committed Dec 11, 2024
1 parent 8c7feb2 commit 3045be2
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 26 deletions.
65 changes: 39 additions & 26 deletions modules/common/development/nix.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ let
mkEnableOption
mkOption
mkIf
mkMerge
types
;
in
Expand All @@ -18,37 +19,49 @@ in
default = null;
description = "Path to the nixpkgs repository";
};
automatic-gc = {
enable = mkEnableOption "Enable automatic garbaze collection";
};
};

config = mkIf cfg.enable {
nix = {
settings = {
experimental-features = [
"nix-command"
"flakes"
];
keep-outputs = true;
keep-derivations = true;
};
config = mkMerge [
(mkIf cfg.enable {
nix = {
settings = {
experimental-features = [
"nix-command"
"flakes"
];
keep-outputs = true;
keep-derivations = true;
};

# avoid scenario where the host rootfs gets filled
# with nixos-rebuild ... switch generated excess
# generations and becomes unbootable
gc = {
automatic = true;
dates = "daily";
options = "--delete-older-than 3d";
};
# avoid scenario where the host rootfs gets filled
# with nixos-rebuild ... switch generated excess
# generations and becomes unbootable
gc = mkIf cfg.automatic-gc.enable {
automatic = true;
dates = "daily";
options = "--delete-older-than 3d";
};

# Set the path and registry so that e.g. nix-shell and repl work
nixPath = lib.mkIf (cfg.nixpkgs != null) [ "nixpkgs=${cfg.nixpkgs}" ];
# Set the path and registry so that e.g. nix-shell and repl work
nixPath = mkIf (cfg.nixpkgs != null) [ "nixpkgs=${cfg.nixpkgs}" ];

registry = lib.mkIf (cfg.nixpkgs != null) {
nixpkgs.to = {
type = "path";
path = cfg.nixpkgs;
registry = mkIf (cfg.nixpkgs != null) {
nixpkgs.to = {
type = "path";
path = cfg.nixpkgs;
};
};
};
};
};
})

(mkIf (!cfg.enable) {
nix = {
enable = lib.mkForce false;
gc.automatic = lib.mkForce false;
};
})
];
}
1 change: 1 addition & 0 deletions modules/microvm/virtualization/microvm/microvm-host.nix
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ in
withHardenedConfigs = true;
};
ghaf.givc.host.enable = true;
ghaf.development.nix-setup.automatic-gc.enable = config.ghaf.development.nix-setup.enable;
services.logind.lidSwitch = "ignore";

# TODO: remove hardcoded paths
Expand Down

0 comments on commit 3045be2

Please sign in to comment.