diff options
author | notgne2 | 2021-05-10 21:40:30 -0700 |
---|---|---|
committer | GitHub | 2021-05-10 21:40:30 -0700 |
commit | f0456d67149edbf27a6cb0a4963386bc2e678267 (patch) | |
tree | 993a8d8aa793a0065c64c7326ed1ff15a5d00097 /flake.nix | |
parent | 9e405fbc5ab5bacbd271fd78c6b6b6877c4d9f8d (diff) | |
parent | 5d5da4898d41cefd1f79c4cf6dd451405ffb8996 (diff) |
Merge pull request #81 from kitnil/dry-activate
Add dry-activate
Diffstat (limited to 'flake.nix')
-rw-r--r-- | flake.nix | 70 |
1 files changed, 42 insertions, 28 deletions
@@ -59,34 +59,48 @@ activate.custom; activate = rec { - custom = base: activate: pkgs.buildEnv { - name = ("activatable-" + base.name); - paths = [ - base - (pkgs.writeTextFile { - name = base.name + "-activate-path"; - text = '' - #!${pkgs.runtimeShell} - set -euo pipefail - - ${activate} - ''; - executable = true; - destination = "/deploy-rs-activate"; - }) - (pkgs.writeTextFile { - name = base.name + "-activate-rs"; - text = '' - #!${pkgs.runtimeShell} - exec ${self.defaultPackage."${system}"}/bin/activate "$@" - ''; - executable = true; - destination = "/activate-rs"; - }) - ]; - }; - - nixos = base: custom base.config.system.build.toplevel '' + custom = + { + __functor = customSelf: base: activate: + pkgs.buildEnv { + name = ("activatable-" + base.name); + paths = + [ + base + (pkgs.writeTextFile { + name = base.name + "-activate-path"; + text = '' + #!${pkgs.runtimeShell} + set -euo pipefail + + if [[ $DRY_ACTIVATE == "1" ]] + then + ${if builtins.hasAttr "dryActivate" customSelf + then + customSelf.dryActivate + else + "echo ${pkgs.writeScript "activate" activate}"} + else + ${activate} + fi + ''; + executable = true; + destination = "/deploy-rs-activate"; + }) + (pkgs.writeTextFile { + name = base.name + "-activate-rs"; + text = '' + #!${pkgs.runtimeShell} + exec ${self.defaultPackage."${system}"}/bin/activate "$@" + ''; + executable = true; + destination = "/activate-rs"; + }) + ]; + }; + }; + + nixos = base: (custom // { dryActivate = "$PROFILE/bin/switch-to-configuration dry-activate"; }) base.config.system.build.toplevel '' # work around https://github.com/NixOS/nixpkgs/issues/73404 cd /tmp |