mirror of
https://github.com/LnL7/nix-darwin.git
synced 2024-12-14 11:57:34 +00:00
Merge pull request #1026 from thecaralice/nochan
Allow disabling channels
This commit is contained in:
commit
076b9a905a
4 changed files with 60 additions and 28 deletions
|
@ -16,6 +16,10 @@ let
|
|||
in
|
||||
|
||||
{
|
||||
imports = [
|
||||
(mkRenamedOptionModule ["environment" "postBuild"] ["environment" "extraSetup"])
|
||||
];
|
||||
|
||||
options = {
|
||||
environment.systemPackages = mkOption {
|
||||
type = types.listOf types.package;
|
||||
|
@ -43,12 +47,6 @@ in
|
|||
description = "A list of profiles used to setup the global environment.";
|
||||
};
|
||||
|
||||
environment.postBuild = mkOption {
|
||||
type = types.lines;
|
||||
default = "";
|
||||
description = "Commands to execute when building the global environment.";
|
||||
};
|
||||
|
||||
environment.extraOutputsToInstall = mkOption {
|
||||
type = types.listOf types.str;
|
||||
default = [];
|
||||
|
@ -147,6 +145,17 @@ in
|
|||
'';
|
||||
type = types.lines;
|
||||
};
|
||||
|
||||
environment.extraSetup = mkOption {
|
||||
type = types.lines;
|
||||
default = "";
|
||||
description = ''
|
||||
Shell fragments to be run after the system environment has been created.
|
||||
This should only be used for things that need to modify the internals
|
||||
of the environment, e.g. generating MIME caches.
|
||||
The environment being built can be accessed at $out.
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
config = {
|
||||
|
@ -188,7 +197,8 @@ in
|
|||
system.path = pkgs.buildEnv {
|
||||
name = "system-path";
|
||||
paths = cfg.systemPackages;
|
||||
inherit (cfg) postBuild pathsToLink extraOutputsToInstall;
|
||||
postBuild = cfg.extraSetup;
|
||||
inherit (cfg) pathsToLink extraOutputsToInstall;
|
||||
};
|
||||
|
||||
system.build.setEnvironment = pkgs.writeText "set-environment" ''
|
||||
|
@ -205,6 +215,5 @@ in
|
|||
system.build.setAliases = pkgs.writeText "set-aliases" ''
|
||||
${concatStringsSep "\n" aliasCommands}
|
||||
'';
|
||||
|
||||
};
|
||||
}
|
||||
|
|
|
@ -380,14 +380,38 @@ in
|
|||
'';
|
||||
};
|
||||
|
||||
channel = {
|
||||
enable = mkOption {
|
||||
description = ''
|
||||
Whether the `nix-channel` command and state files are made available on the machine.
|
||||
|
||||
The following files are initialized when enabled:
|
||||
- `/nix/var/nix/profiles/per-user/root/channels`
|
||||
- `$HOME/.nix-defexpr/channels` (on login)
|
||||
|
||||
Disabling this option will not remove the state files from the system.
|
||||
'';
|
||||
type = types.bool;
|
||||
default = true;
|
||||
};
|
||||
};
|
||||
|
||||
# Definition differs substantially from NixOS module
|
||||
nixPath = mkOption {
|
||||
type = nixPathType;
|
||||
default = [
|
||||
default = lib.optionals cfg.channel.enable [
|
||||
# Include default path <darwin-config>.
|
||||
{ darwin-config = "${config.environment.darwinConfig}"; }
|
||||
"/nix/var/nix/profiles/per-user/root/channels"
|
||||
];
|
||||
|
||||
defaultText = lib.literalExpression ''
|
||||
lib.optionals cfg.channel.enable [
|
||||
# Include default path <darwin-config>.
|
||||
{ darwin-config = "${config.environment.darwinConfig}"; }
|
||||
{ darwin-config = "''${config.environment.darwinConfig}"; }
|
||||
"/nix/var/nix/profiles/per-user/root/channels"
|
||||
];
|
||||
]
|
||||
'';
|
||||
description = ''
|
||||
The default Nix expression search path, used by the Nix
|
||||
evaluator to look up paths enclosed in angle brackets
|
||||
|
@ -744,27 +768,21 @@ in
|
|||
];
|
||||
|
||||
# Not in NixOS module
|
||||
nix.nixPath = mkMerge [
|
||||
(mkIf (config.system.stateVersion < 2) (mkDefault
|
||||
[ "darwin=$HOME/.nix-defexpr/darwin"
|
||||
"darwin-config=$HOME/.nixpkgs/darwin-configuration.nix"
|
||||
"/nix/var/nix/profiles/per-user/root/channels"
|
||||
]))
|
||||
(mkIf (config.system.stateVersion > 3) (mkOrder 1200
|
||||
[ { darwin-config = "${config.environment.darwinConfig}"; }
|
||||
"/nix/var/nix/profiles/per-user/root/channels"
|
||||
]))
|
||||
];
|
||||
nix.nixPath = mkIf (config.system.stateVersion < 2) (mkDefault [
|
||||
"darwin=$HOME/.nix-defexpr/darwin"
|
||||
"darwin-config=$HOME/.nixpkgs/darwin-configuration.nix"
|
||||
"/nix/var/nix/profiles/per-user/root/channels"
|
||||
]);
|
||||
|
||||
# Set up the environment variables for running Nix.
|
||||
environment.variables = cfg.envVars // { NIX_PATH = cfg.nixPath; };
|
||||
|
||||
environment.extraInit =
|
||||
''
|
||||
environment.extraInit = mkMerge [
|
||||
(mkIf cfg.channel.enable ''
|
||||
if [ -e "$HOME/.nix-defexpr/channels" ]; then
|
||||
export NIX_PATH="$HOME/.nix-defexpr/channels''${NIX_PATH:+:$NIX_PATH}"
|
||||
fi
|
||||
'' +
|
||||
'')
|
||||
# Not in NixOS module
|
||||
''
|
||||
# Set up secure multi-user builds: non-root users build through the
|
||||
|
@ -772,7 +790,12 @@ in
|
|||
if [ ! -w /nix/var/nix/db ]; then
|
||||
export NIX_REMOTE=daemon
|
||||
fi
|
||||
'';
|
||||
''
|
||||
];
|
||||
|
||||
environment.extraSetup = mkIf (!cfg.channel.enable) ''
|
||||
rm --force $out/bin/nix-channel
|
||||
'';
|
||||
|
||||
nix.nrBuildUsers = mkDefault (max 32 (if cfg.settings.max-jobs == "auto" then 0 else cfg.settings.max-jobs));
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ in
|
|||
environment.pathsToLink = [ "/info" "/share/info" ];
|
||||
environment.extraOutputsToInstall = [ "info" ];
|
||||
|
||||
environment.postBuild = ''
|
||||
environment.extraSetup = ''
|
||||
if test -w $out/share/info; then
|
||||
shopt -s nullglob
|
||||
for i in $out/share/info/*.info $out/share/info/*.info.gz; do
|
||||
|
|
|
@ -236,7 +236,7 @@ in
|
|||
|
||||
system.checks.verifyNixChannels = mkOption {
|
||||
type = types.bool;
|
||||
default = true;
|
||||
default = config.nix.channel.enable;
|
||||
description = "Whether to run the nix-channels validation checks.";
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue