From 46ac71aa245549965a3d9dfdabf6421b39f62289 Mon Sep 17 00:00:00 2001 From: Oleg Pykhalov Date: Wed, 31 Mar 2021 13:14:10 +0300 Subject: Add dry activate argument. --- flake.nix | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'flake.nix') diff --git a/flake.nix b/flake.nix index d87702f..75ea2b7 100644 --- a/flake.nix +++ b/flake.nix @@ -90,7 +90,11 @@ # work around https://github.com/NixOS/nixpkgs/issues/73404 cd /tmp - $PROFILE/bin/switch-to-configuration switch + if [[ $DRY_ACTIVATE == "1" ]]; then + $PROFILE/bin/switch-to-configuration dry-activate + else + $PROFILE/bin/switch-to-configuration switch + fi # https://github.com/serokell/deploy-rs/issues/31 ${with base.config.boot.loader; -- cgit v1.2.3 From 6093dc02e98ae68f73c997c8d5d18f19074a46e1 Mon Sep 17 00:00:00 2001 From: Oleg Pykhalov Date: Wed, 7 Apr 2021 13:33:50 +0300 Subject: flake: Add optional dryActivate argument to activate.custom --- flake.nix | 80 +++++++++++++++++++++++++++++++++++++-------------------------- 1 file changed, 47 insertions(+), 33 deletions(-) (limited to 'flake.nix') diff --git a/flake.nix b/flake.nix index 75ea2b7..424718c 100644 --- a/flake.nix +++ b/flake.nix @@ -59,42 +59,56 @@ 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 = + { + __toString = customSelf: "TODO: dryActivate"; + __functor = customSelf: base: activate: + pkgs.buildEnv { + name = ("activatable-" + base.name); + paths = + let + hasDryActivate = builtins.hasAttr "dryActivate" customSelf; + in [ + base + (pkgs.writeTextFile { + name = base.name + "-activate-path"; + text = '' + #!${pkgs.runtimeShell} + set -euo pipefail + + if [[ $DRY_ACTIVATE == "1" ]] + then + if ${pkgs.lib.boolToString hasDryActivate} + then + ${if hasDryActivate then customSelf.dryActivate else ":"} + else + echo ${pkgs.writeScript "activate" activate} + fi + 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 - if [[ $DRY_ACTIVATE == "1" ]]; then - $PROFILE/bin/switch-to-configuration dry-activate - else - $PROFILE/bin/switch-to-configuration switch - fi + $PROFILE/bin/switch-to-configuration switch # https://github.com/serokell/deploy-rs/issues/31 ${with base.config.boot.loader; -- cgit v1.2.3 From 920c9d2ed4034e2200c948868c7bd510e58b1371 Mon Sep 17 00:00:00 2001 From: Oleg Pykhalov Date: Fri, 16 Apr 2021 10:28:01 +0300 Subject: Apply notgne2 suggestions. --- flake.nix | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) (limited to 'flake.nix') diff --git a/flake.nix b/flake.nix index 424718c..d718e83 100644 --- a/flake.nix +++ b/flake.nix @@ -61,14 +61,11 @@ activate = rec { custom = { - __toString = customSelf: "TODO: dryActivate"; __functor = customSelf: base: activate: pkgs.buildEnv { name = ("activatable-" + base.name); paths = - let - hasDryActivate = builtins.hasAttr "dryActivate" customSelf; - in [ + [ base (pkgs.writeTextFile { name = base.name + "-activate-path"; @@ -78,12 +75,11 @@ if [[ $DRY_ACTIVATE == "1" ]] then - if ${pkgs.lib.boolToString hasDryActivate} - then - ${if hasDryActivate then customSelf.dryActivate else ":"} - else - echo ${pkgs.writeScript "activate" activate} - fi + ${if builtins.hasAttr "dryActivate" customSelf + then + customSelf.dryActivate + else + "echo ${pkgs.writeScript "activate" activate}"} else ${activate} fi -- cgit v1.2.3