From 0a070a821c921f14dfe64cc6aaed2273615e0b78 Mon Sep 17 00:00:00 2001 From: Gabriel Arazas Date: Wed, 13 Dec 2023 19:35:35 +0800 Subject: nixos/guix: add Guix home support (cherry picked from commit a73ae4bf9fdf3eadcba76109b76bc5746182dbfb) --- nixos/modules/services/misc/guix/default.nix | 35 +++++++++++++++++++++------- 1 file changed, 27 insertions(+), 8 deletions(-) (limited to 'nixos') diff --git a/nixos/modules/services/misc/guix/default.nix b/nixos/modules/services/misc/guix/default.nix index 2bfa3b77971f4..42a0e854b7092 100644 --- a/nixos/modules/services/misc/guix/default.nix +++ b/nixos/modules/services/misc/guix/default.nix @@ -22,11 +22,19 @@ let }) (builtins.genList guixBuildUser numberOfUsers)); - # A set of Guix user profiles to be linked at activation. + # A set of Guix user profiles to be linked at activation. All of these should + # be default profiles managed by Guix CLI and the profiles are located in + # `${cfg.stateDir}/profiles/per-user/$USER/$PROFILE`. guixUserProfiles = { - # The current Guix profile that is created through `guix pull`. + # The default Guix profile managed by `guix pull`. Take note this should be + # the profile with the most precedence in `PATH` env to let users use their + # updated versions of `guix` CLI. "current-guix" = "\${XDG_CONFIG_HOME}/guix/current"; + # The default Guix home profile. This profile contains more than exports + # such as an activation script at `$GUIX_HOME_PROFILE/activate`. + "guix-home" = "$HOME/.guix-home/profile"; + # The default Guix profile similar to $HOME/.nix-profile from Nix. "guix-profile" = "$HOME/.guix-profile"; }; @@ -256,20 +264,31 @@ in # ephemeral setups where only certain part of the filesystem is # persistent (e.g., "Erase my darlings"-type of setup). system.userActivationScripts.guix-activate-user-profiles.text = let + guixProfile = profile: "${cfg.stateDir}/guix/profiles/per-user/\${USER}/${profile}"; + linkProfile = profile: location: let + userProfile = guixProfile profile; + in '' + [ -d "${userProfile}" ] && [ -L "${location}" ] || ln -sf "${userProfile}" "${location}" + ''; linkProfileToPath = acc: profile: location: let - guixProfile = "${cfg.stateDir}/guix/profiles/per-user/\${USER}/${profile}"; - in acc + '' - [ -d "${guixProfile}" ] && [ -L "${location}" ] || ln -sf "${guixProfile}" "${location}" - ''; + in acc + (linkProfile profile location); - activationScript = lib.foldlAttrs linkProfileToPath "" guixUserProfiles; + # This should contain export-only Guix user profiles. The rest of it is + # handled manually in the activation script. + guixUserProfiles' = lib.attrsets.removeAttrs guixUserProfiles [ "guix-home" ]; + + linkExportsScript = lib.foldlAttrs linkProfileToPath "" guixUserProfiles'; in '' # Don't export this please! It is only expected to be used for this # activation script and nothing else. XDG_CONFIG_HOME=''${XDG_CONFIG_HOME:-$HOME/.config} # Linking the usual Guix profiles into the home directory. - ${activationScript} + ${linkExportsScript} + + # Activate all of the default Guix non-exports profiles manually. + ${linkProfile "guix-home" "$HOME/.guix-home"} + [ -L "$HOME/.guix-home" ] && "$HOME/.guix-home/activate" ''; # GUIX_LOCPATH is basically LOCPATH but for Guix libc which in turn used by -- cgit 1.4.1 From 8f011343f3a32511666b54fa45375a944e8130e4 Mon Sep 17 00:00:00 2001 From: Gabriel Arazas Date: Wed, 20 Dec 2023 22:04:01 +0800 Subject: nixos/guix: fix conditional linking of profiles (cherry picked from commit b7ece537bb396412f9980b4fba62d6d13014cc6d) --- nixos/modules/services/misc/guix/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'nixos') diff --git a/nixos/modules/services/misc/guix/default.nix b/nixos/modules/services/misc/guix/default.nix index 42a0e854b7092..7174ff36b7090 100644 --- a/nixos/modules/services/misc/guix/default.nix +++ b/nixos/modules/services/misc/guix/default.nix @@ -268,7 +268,7 @@ in linkProfile = profile: location: let userProfile = guixProfile profile; in '' - [ -d "${userProfile}" ] && [ -L "${location}" ] || ln -sf "${userProfile}" "${location}" + [ -d "${userProfile}" ] && ln -sfn "${userProfile}" "${location}" ''; linkProfileToPath = acc: profile: location: let in acc + (linkProfile profile location); -- cgit 1.4.1 From af26d46b07aa727179264f2949789110ae77592a Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 12 Jan 2024 02:01:59 +0100 Subject: Revert "nixos/gitlab: fix database config when no passwordfile is defined" (#280393) (cherry picked from commit d4e9e3c6ccb3127c80d6486194a6ce4ea0beb853) Co-authored-by: Yureka --- nixos/modules/services/misc/gitlab.nix | 1 - 1 file changed, 1 deletion(-) (limited to 'nixos') diff --git a/nixos/modules/services/misc/gitlab.nix b/nixos/modules/services/misc/gitlab.nix index 954defbcc4ddd..32c3c858433c5 100644 --- a/nixos/modules/services/misc/gitlab.nix +++ b/nixos/modules/services/misc/gitlab.nix @@ -1383,7 +1383,6 @@ in { '' else '' jq <${pkgs.writeText "database.yml" (builtins.toJSON databaseConfig)} \ - '${if lib.versionAtLeast (lib.getVersion cfg.packages.gitlab) "15.9" then ".production.main as $main | del(.production.main) | .production |= {main: $main} + ." else ""}' \ >'${cfg.statePath}/config/database.yml' '' } -- cgit 1.4.1 From ddbecb8bce70bd605f8ca6334bb9493ca8cebf57 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 12 Jan 2024 02:04:03 +0100 Subject: Revert "nixos/gitlab: Add CI database connection for >=15.9" (#280396) (cherry picked from commit 2e06a69fb282529a3abf2e255a2bb3f61d4753c9) Co-authored-by: Yureka --- nixos/modules/services/misc/gitlab.nix | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'nixos') diff --git a/nixos/modules/services/misc/gitlab.nix b/nixos/modules/services/misc/gitlab.nix index 32c3c858433c5..b399ccc38f58d 100644 --- a/nixos/modules/services/misc/gitlab.nix +++ b/nixos/modules/services/misc/gitlab.nix @@ -27,13 +27,7 @@ let encoding = "utf8"; pool = cfg.databasePool; } // cfg.extraDatabaseConfig; - in if lib.versionAtLeast (lib.getVersion cfg.packages.gitlab) "15.9" then { - production.main = val; - # Starting with GitLab 15.9, single connections were deprecated and will be - # removed in GitLab 17.0. The CI connection however requires database_tasks set - # to false. - production.ci = val // { database_tasks = false; }; - } else if lib.versionAtLeast (lib.getVersion cfg.packages.gitlab) "15.0" then { + in if lib.versionAtLeast (lib.getVersion cfg.packages.gitlab) "15.0" then { production.main = val; } else { production = val; @@ -1378,7 +1372,7 @@ in { fi jq <${pkgs.writeText "database.yml" (builtins.toJSON databaseConfig)} \ - '.${if lib.versionAtLeast (lib.getVersion cfg.packages.gitlab) "15.0" then "production.main" else "production"}.password = $ENV.db_password ${if lib.versionAtLeast (lib.getVersion cfg.packages.gitlab) "15.9" then "| .production.ci.password = $ENV.db_password | .production.main as $main | del(.production.main) | .production |= {main: $main} + ." else ""}' \ + '.${if lib.versionAtLeast (lib.getVersion cfg.packages.gitlab) "15.0" then "production.main" else "production"}.password = $ENV.db_password' \ >'${cfg.statePath}/config/database.yml' '' else '' -- cgit 1.4.1