my nixos/home-manager configuration
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

refactor git and jujutsu conditional config

+181 -46
+32
home-manager/clever-cloud.nix
··· 1 1 { 2 + config, 2 3 pkgs, 4 + user, 3 5 ... 4 6 }: 5 7 ··· 15 17 ]; 16 18 17 19 programs = { 20 + # cli 21 + git = { 22 + enable = true; 23 + scopes = [ 24 + { 25 + when = [ 26 + "${user.homeDirectory}/clever-cloud" 27 + ]; 28 + config = { 29 + user.email = "${user.name}.${user.family}@clever-cloud.com"; 30 + user.signingKey = config.home.file.".ssh/clever-cloud.pub".text; 31 + }; 32 + } 33 + ]; 34 + }; 35 + jujutsu = { 36 + enable = true; 37 + scopes = [ 38 + { 39 + when = [ 40 + "${user.homeDirectory}/clever-cloud" 41 + ]; 42 + config = { 43 + user.email = "${user.name}.${user.family}@clever-cloud.com"; 44 + signing.key = config.home.file.".ssh/clever-cloud.pub".text; 45 + }; 46 + } 47 + ]; 48 + }; 49 + 18 50 # gui 19 51 discord.enable = true; 20 52 ghostty.enable = true;
+31
home-manager/desktop.nix
··· 1 1 { 2 + config, 2 3 pkgs, 3 4 user, 4 5 ... ··· 18 19 ]; 19 20 20 21 programs = { 22 + # cli 23 + git = { 24 + enable = true; 25 + scopes = [ 26 + { 27 + when = [ 28 + "${user.homeDirectory}/clever-cloud" 29 + ]; 30 + config = { 31 + user.email = "${user.name}.${user.family}@clever-cloud.com"; 32 + user.signingKey = config.home.file.".ssh/clever-cloud.pub".text; 33 + }; 34 + } 35 + ]; 36 + }; 37 + jujutsu = { 38 + enable = true; 39 + scopes = [ 40 + { 41 + when = [ 42 + "${user.homeDirectory}/clever-cloud" 43 + ]; 44 + config = { 45 + user.email = "${user.name}.${user.family}@clever-cloud.com"; 46 + signing.key = config.home.file.".ssh/clever-cloud.pub".text; 47 + }; 48 + } 49 + ]; 50 + }; 51 + 21 52 # gui 22 53 discord.enable = true; 23 54 ghostty.enable = true;
+31
home-manager/laptop.nix
··· 1 1 { 2 + config, 2 3 pkgs, 3 4 user, 4 5 ... ··· 18 19 ]; 19 20 20 21 programs = { 22 + # cli 23 + git = { 24 + enable = true; 25 + scopes = [ 26 + { 27 + when = [ 28 + "${user.homeDirectory}/clever-cloud" 29 + ]; 30 + config = { 31 + user.email = "${user.name}.${user.family}@clever-cloud.com"; 32 + user.signingKey = config.home.file.".ssh/clever-cloud.pub".text; 33 + }; 34 + } 35 + ]; 36 + }; 37 + jujutsu = { 38 + enable = true; 39 + scopes = [ 40 + { 41 + when = [ 42 + "${user.homeDirectory}/clever-cloud" 43 + ]; 44 + config = { 45 + user.email = "${user.name}.${user.family}@clever-cloud.com"; 46 + signing.key = config.home.file.".ssh/clever-cloud.pub".text; 47 + }; 48 + } 49 + ]; 50 + }; 51 + 21 52 # gui 22 53 discord.enable = true; 23 54 ghostty.enable = true;
+58 -36
home-manager/modules/git.nix
··· 1 1 { 2 2 config, 3 + pkgs, 3 4 lib, 4 5 user, 5 6 ... ··· 7 8 8 9 let 9 10 cfg = config.programs.git; 11 + 12 + toml = pkgs.formats.toml { }; 13 + 14 + includeIfFor = 15 + { when, config }: 16 + let 17 + file = toml.generate "config.toml" config; 18 + in 19 + builtins.map (p: { 20 + name = "includeIf \"gitdir:${p}\""; 21 + value = { 22 + path = builtins.toString file; 23 + }; 24 + }) when; 10 25 in 11 26 { 27 + options.programs.git = { 28 + scopes = lib.mkOption { 29 + type = lib.types.listOf ( 30 + lib.types.submodule { 31 + options = { 32 + when = lib.mkOption { 33 + type = lib.types.listOf lib.types.str; 34 + }; 35 + config = lib.mkOption { 36 + type = lib.types.attrs; 37 + }; 38 + }; 39 + } 40 + ); 41 + default = [ ]; 42 + }; 43 + }; 44 + 12 45 config = lib.mkIf cfg.enable { 13 46 programs.git = { 14 47 delta = { 15 48 enable = true; 16 49 }; 17 - extraConfig = { 18 - user = { 19 - name = user.fullName; 20 - email = user.email; 21 - signingKey = config.home.file.".ssh/master.pub".text; 22 - }; 23 - gpg = { 24 - format = "ssh"; 25 - }; 26 - "gpg \"ssh\"" = { 27 - program = "op-ssh-sign"; 28 - }; 29 - tag = { 30 - gpgSign = true; 31 - }; 32 - init = { 33 - defaultBranch = "main"; 34 - }; 35 - pull = { 36 - rebase = true; 37 - }; 38 - "includeIf \"gitdir:${user.homeDirectory}/clever-cloud\"" = { 39 - path = builtins.toString config.xdg.configFile."git/work".source; 40 - }; 41 - "includeIf \"gitdir:${user.homeDirectory}/Code/clever-cloud\"" = { 42 - path = builtins.toString config.xdg.configFile."git/work".source; 43 - }; 44 - }; 50 + extraConfig = lib.mkMerge [ 51 + { 52 + user = { 53 + name = user.fullName; 54 + email = user.email; 55 + signingKey = config.home.file.".ssh/master.pub".text; 56 + }; 57 + gpg = { 58 + format = "ssh"; 59 + }; 60 + "gpg \"ssh\"" = { 61 + program = "op-ssh-sign"; 62 + }; 63 + tag = { 64 + gpgSign = true; 65 + }; 66 + init = { 67 + defaultBranch = "main"; 68 + }; 69 + pull = { 70 + rebase = true; 71 + }; 72 + } 73 + (lib.listToAttrs (lib.concatMap includeIfFor cfg.scopes)) 74 + ]; 45 75 ignores = [ 46 76 ".zed" 47 77 ".direnv/" 48 78 ".env" 49 79 ".envrc.local" 50 80 ]; 51 - }; 52 - 53 - xdg.configFile."git/work" = { 54 - text = '' 55 - [user] 56 - email = "${user.name}.${user.family}@clever-cloud.com" 57 - signingKey = "${config.home.file.".ssh/clever-cloud.pub".text}" 58 - ''; 59 81 }; 60 82 }; 61 83 }
+29 -10
home-manager/modules/jujutsu.nix
··· 7 7 8 8 let 9 9 cfg = config.programs.jujutsu; 10 + 11 + toWhenList = 12 + items: 13 + builtins.map ( 14 + { when, config }: 15 + config 16 + // { 17 + "--when".repositories = when; 18 + } 19 + ) items; 10 20 in 11 21 { 22 + options.programs.jujutsu = { 23 + scopes = lib.mkOption { 24 + type = lib.types.listOf ( 25 + lib.types.submodule { 26 + options = { 27 + when = lib.mkOption { 28 + type = lib.types.listOf lib.types.str; 29 + }; 30 + config = lib.mkOption { 31 + type = lib.types.attrs; 32 + }; 33 + }; 34 + } 35 + ); 36 + default = [ ]; 37 + }; 38 + }; 39 + 12 40 config = lib.mkIf cfg.enable { 13 41 programs.jujutsu = { 14 42 settings = { ··· 39 67 push-new-bookmarks = true; 40 68 private-commits = "description(glob:'private:*')"; 41 69 }; 42 - "--scope" = [ 43 - { 44 - "--when".repositories = [ 45 - "${user.homeDirectory}/clever-cloud" 46 - "${user.homeDirectory}/Code/clever-cloud" 47 - ]; 48 - user.email = "${user.name}.${user.family}@clever-cloud.com"; 49 - signing.key = config.home.file.".ssh/clever-cloud.pub".text; 50 - } 51 - ]; 70 + "--scope" = toWhenList cfg.scopes; 52 71 }; 53 72 }; 54 73