Skip to content

Commit

Permalink
Add production cache (#12)
Browse files Browse the repository at this point in the history
* feat(cache): add klarkc builder

* feat(cache): upgrade keys

* feat: change nix cache

* feat(cache): add github

* feat(cache): remove cachix and add builder user

* feat(cache): readd builder, remove other keys

* fix(cache): add builder as trusted user

* ci(test): add nix cache

* ci(test): add nix version

* fix(cache): missing config

* ci(test): add debug

* ci(test): change to manual ssh key

* ci(test): disable check

* ci(test): move key add

* ci(test): readd agent

* ci(test): add example

* ci(test): tryout with ng

* ci(test): try out derivation and all

* ci(test): remove derivation

* ci(test): change nix installer

* ci(test): add from and flags

* ci(test): change to closure

* ci(test): change to xargs

* ci(test): return to nix copy simplified

* ci(test): return to cachix install

* ci(test): reenable check

* ci(test): try with store

* ci(test): remove store and dervir, add def

* ci(test): add verbose, subst
  • Loading branch information
klarkc authored Dec 22, 2023
1 parent 5b87eeb commit c804397
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 15 deletions.
14 changes: 10 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,17 @@ jobs:
- uses: actions/checkout@v3
- uses: cachix/install-nix-action@v20
with:
install_url: https://releases.nixos.org/nix/nix-2.19.1/install
extra_nix_config: |
accept-flake-config = true
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
- uses: cachix/cachix-action@v12
- uses: webfactory/[email protected]
with:
name: klarkc
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
- run: nix flake check
ssh-private-key: ${{ secrets.BUILDER_TOKEN }}
- uses: gacts/run-and-post-run@v1
with:
run: nix -v flake check -L --show-trace
post: |
mkdir -p ~/.ssh/ && touch ~/.ssh/known_hosts
ssh-keyscan cache.tcp4.me >> ~/.ssh/known_hosts
nix -v copy -s --all --to ssh://[email protected]
9 changes: 4 additions & 5 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@
inherit (setups.cache.machines) cache-vultr;
};

packages.${system} = {
packages.${system} = rec {
default = cache-vm;
inherit (setups.recover.packages) recover-efi recover-vm;
inherit (setups.cache.packages) cache-vm;
};
Expand All @@ -65,12 +66,10 @@
# Nix should ask for permission before using it,
# but remove it here if you do not want it to.
extra-substituters = [
"https://klarkc.cachix.org?priority=99"
"https://cache.nixos.org"
"https://cache.tcp4.me"
];
extra-trusted-public-keys = [
"klarkc.cachix.org-1:R+z+m4Cq0hMgfZ7AQ42WRpGuHJumLLx3k0XhwpNFq9U="
"cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY="
"cache.tcp4.me:cmk2Iz81lQuX7FtTUcBgtqgI70E8p6SOamNAIcFDSew="
];
};
}
1 change: 1 addition & 0 deletions secrets/builder.pub
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGPSuuFCsXXHk6JYXZ+hIrZGjb3d4wwRPoks0mrMmidk klarkc@ssdinarch
Binary file modified secrets/cache.age
Binary file not shown.
1 change: 1 addition & 0 deletions secrets/cache.pub
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
cache.tcp4.me:cmk2Iz81lQuX7FtTUcBgtqgI70E8p6SOamNAIcFDSew=
20 changes: 14 additions & 6 deletions setups/cache/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ let
domain = "cache.tcp4.me";
home = "/home/klarkc";
email = "[email protected]";
authorizedKeys.keys = [
(builtins.readFile ../../secrets/klarkc.pub)
];
cache-module = { disks ? [ "/dev/vda" ], config, ... }:
{
imports = [
Expand All @@ -19,9 +16,9 @@ let
disko
];
# cd secrets
# nix-store --generate-binary-cache-key cache.tcp4.me ./cache ./cache.skey
# cat cache | nix run github:ryantm/agenix -- -e cache.age -i cache-vultr.pub
# nix-store --generate-binary-cache-key cache.tcp4.me ./cache ./cache.pub
# scp ssh://[email protected]:/etc/ssh/ssh_host_ed25519_key.pub cache-vultr.pub
# cat cache | nix run github:ryantm/agenix -- -e cache.age -i cache-vultr.pub
age.secrets.cache.file = "${secrets}/cache.age";
system.stateVersion = config.system.nixos.version;
boot.loader.systemd-boot.enable = true;
Expand All @@ -30,6 +27,15 @@ let
22
config.services.nix-serve.port
];
# builders
nix.settings.trusted-users = [ "builder" ];
users.users.builder = {
home = "/home/builder";
isNormalUser = true;
openssh. authorizedKeys.keys = [
(builtins.readFile ../../secrets/builder.pub)
];
};
# cache service
services.nix-serve = {
enable = true;
Expand All @@ -41,7 +47,9 @@ let
'';
# SSH
services.sshd.enable = true;
users.users.root.openssh = { inherit authorizedKeys; };
users.users.root.openssh.authorizedKeys.keys = [
(builtins.readFile ../../secrets/klarkc.pub)
];
# beesd
services.beesd.filesystems = {
root = {
Expand Down

0 comments on commit c804397

Please sign in to comment.