Skip to content

Commit

Permalink
fix: factor ssh keys in one place
Browse files Browse the repository at this point in the history
  • Loading branch information
mrnossiom committed May 6, 2024
1 parent d2d97f0 commit bfdba41
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 27 deletions.
2 changes: 0 additions & 2 deletions Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,3 @@ build:

check: build
@unlink result

# TODO: custom rekey entry to rekey every secret avoiding to retype it everytime
12 changes: 4 additions & 8 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
forAllSystems = genAttrs [ "x86_64-linux" "aarch64-linux" "aarch64-darwin" ];
forAllPkgs = function: forAllSystems (system: function pkgs.${system});

keys = import ./secrets/keys.nix;
flakeLib = import ./lib/flake (nixpkgs // { inherit self; });

# This sould be the only constructed nixpkgs instance in this flake
Expand All @@ -69,28 +70,23 @@
lib = forAllPkgs (import ./lib);

nixosConfigurations = with flakeLib;
let
userKeys = [
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJdt7atyPTOfaBIsgDYYb0DG1yid2u78abaCDji6Uxgi"
];
in
{
# Desktops
"neo-wiro-laptop" = createSystem pkgs."x86_64-linux" [
(system "neo-wiro-laptop" "laptop")
(managedDiskLayout "luks-btrfs" { device = "nvme0n1"; swapSize = 12; })
(user "milomoisson" { description = "Milo Moisson"; profile = "desktop"; keys = userKeys; })
(user "milomoisson" { description = "Milo Moisson"; profile = "desktop"; keys = keys.users; })
];

"archaic-wiro-laptop" = createSystem pkgs."x86_64-linux" [
(system "archaic-wiro-laptop" "laptop")
(user "milomoisson" { description = "Milo Moisson"; profile = "desktop"; keys = userKeys; })
(user "milomoisson" { description = "Milo Moisson"; profile = "desktop"; keys = keys.users; })
];

# # Servers
# "weird-row-server" = createSystem pkgs."x86_64-linux" [
# (system "weird-row-server" "server")
# (user "milomoisson" { description = "Milo Moisson"; profile = "minimal"; keys = userKeys; })
# (user "milomoisson" { description = "Milo Moisson"; profile = "minimal"; keys = keys.users; })
# ];
};

Expand Down
4 changes: 2 additions & 2 deletions home-manager/profiles/desktop.nix
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,8 @@ in
home.file."${config.home.sessionVariables.CARGO_HOME}/config.toml".source = toml-format.generate "cargo-config" {
build.rustc-wrapper = getExe' pkgs.sccache "sccache";

registry.global-credential-providers = ["cargo:token-from-stdout cat ${config.age.secrets.api-crates-io.path}"];
registry.global-credential-providers = [ "cargo:token-from-stdout ${pkgs.writeShellScript "get-crates-io-token" "cat ${config.age.secrets.api-crates-io.path}"}" ];

source = {
local-mirror.registry = "sparse+http://local.crates.io:8080/index/";
# crates-io.replace-with = "local-mirror";
Expand Down
6 changes: 5 additions & 1 deletion nixos/hardware/neo-wiro-laptop.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
{ self, config, lib, ... }:
{ self
, config
, lib
, ...
}:

let
inherit (self.outputs) nixosModules;
Expand Down
2 changes: 2 additions & 0 deletions nixos/modules/nix.nix
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,12 @@ with lib;
extra-substituters = [
"https://nix-community.cachix.org"
"https://mrnossiom.cachix.org"
"https://radicle.cachix.org"
];
extra-trusted-public-keys = [
"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
"mrnossiom.cachix.org-1:WKo+xfDFaT6pRP4YiIFsEXvyBzI/Pm9uGhURgF1wlQg="
"radicle.cachix.org-1:x7jrVNzziAP6GAAJF2wvgJBndqRhmh2EylgWr93ofx0="
];
};
};
Expand Down
3 changes: 1 addition & 2 deletions nixos/profiles/laptop.nix
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{ self
, lib
{ lib
, config
, pkgs
, ...
Expand Down
14 changes: 14 additions & 0 deletions secrets/keys.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
rec {
# Machine SSH key (/etc/ssh/ssh_host_ed25519_key.pub)
archaic = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJDuBHC0f7N0q1KRczJMoaBVdY0JFOtcpPy6WlYsoxUh";
neo = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAINR1/9o1HLnSRkXt3xxAM5So1YCCNdJpBN1leSu7giuR";
systems = [ archaic neo ];

# Sessions specific age key (~/.ssh/id_home_manager.pub)
neo-milomoisson = "age1vz2zmduaqhaw5jrqh277pmp36plyth8rz5k9ccxeftfcl2nlhalqwvx5xz";
sessions = [ neo-milomoisson ];

# User keys (~/.ssh/id_ed25519.pub)
milomoisson = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJdt7atyPTOfaBIsgDYYb0DG1yid2u78abaCDji6Uxgi";
users = [ milomoisson ];
}
13 changes: 1 addition & 12 deletions secrets/secrets.nix
Original file line number Diff line number Diff line change
@@ -1,16 +1,5 @@
let
# Machine SSH key (/etc/ssh/ssh_host_ed25519_key.pub)
archaic = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJDuBHC0f7N0q1KRczJMoaBVdY0JFOtcpPy6WlYsoxUh";
neo = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAINR1/9o1HLnSRkXt3xxAM5So1YCCNdJpBN1leSu7giuR";
systems = [ archaic neo ];

# Sessions specific age key (~/.ssh/id_home_manager.pub)
neo-milomoisson = "age1vz2zmduaqhaw5jrqh277pmp36plyth8rz5k9ccxeftfcl2nlhalqwvx5xz";
sessions = [ neo-milomoisson ];

# User keys (~/.ssh/id_ed25519.pub)
milomoisson = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJdt7atyPTOfaBIsgDYYb0DG1yid2u78abaCDji6Uxgi";
users = [ milomoisson ];
inherit (import ./keys.nix) users systems sessions;

nixos = systems ++ users;
home-manager = sessions ++ users;
Expand Down

0 comments on commit bfdba41

Please sign in to comment.