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 garbage collection in ghaf-host only

Signed-off-by: Ganga Ram <[email protected]>
  • Loading branch information
gngram committed Jan 2, 2025
1 parent e504823 commit 15ea8ab
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 25 deletions.
52 changes: 27 additions & 25 deletions modules/common/development/nix.nix
Original file line number Diff line number Diff line change
Expand Up @@ -18,36 +18,38 @@ in
default = null;
description = "Path to the nixpkgs repository";
};
automatic-gc = {
enable = mkEnableOption "Enable automatic garbage collection";
};
};

config = mkIf cfg.enable {
nix = {
settings = {
experimental-features = [
"nix-command"
"flakes"
];
keep-outputs = true;
keep-derivations = true;
};
config.nix = {
inherit (cfg) enable;
settings = mkIf cfg.enable {
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 = {
automatic = cfg.enable;
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 = lib.mkIf (cfg.enable && cfg.nixpkgs != null) [ "nixpkgs=${cfg.nixpkgs}" ];

registry = lib.mkIf (cfg.nixpkgs != null) {
nixpkgs.to = {
type = "path";
path = cfg.nixpkgs;
};
registry = lib.mkIf (cfg.enable && cfg.nixpkgs != null) {
nixpkgs.to = {
type = "path";
path = cfg.nixpkgs;
};
};
};
Expand Down
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 @@ -73,6 +73,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 15ea8ab

Please sign in to comment.