A NixOS module to run Jenkins, optimized specifically for running projects using Nix.
Jenkinsfile
nix: provides nixCI (using nixci) to build all flake outputs, and sets env.FLAKE_OUTPUTS to the list of outputs built.
--no-update-lock-file (thus fails on out of sync flake.lock files)nixcicachixPush and cachixUse pipeline steps
cachixPush will push the env.FLAKE_OUTPUTS built by the nix featuredockerPush pipeline stepgithubApp: provides Github integration for CI status reportingTo update the plugins, run nix-prefetch-jenkins-plugins > nix/jenkins/plugins.nix. nix-prefetch-jenkins-plugins must have been added to the devShell. See the aforementioned example.
We use sops-nix to manage secrets used by the individual CI features. Convert your SSH key (ed25519) to age, which sops uses. With macOS & 1Password, it would look like:
nix run nixpkgs#ssh-to-age <<< "$(op read 'op://Personal/id_ed25519/public key')"
nix run nixpkgs#ssh-to-age -- --private-key -i <(op read 'op://Personal/id_ed25519/actual private') > ~/.config/sops/age/keys.txt
# ^ $HOME/Library/Application\ Support/sops/age/keys.txt actually
You also want to get the host key (ssh-keyscan localhost | ssh-to-age) of the machine being deployed.
Put both these public age keys in .sops.yaml of the repository.
Nix
92.1%
Groovy
7.9%
A NixOS module to run Jenkins, optimized specifically for running projects using Nix.
Jenkinsfile
nix: provides nixCI (using nixci) to build all flake outputs, and sets env.FLAKE_OUTPUTS to the list of outputs built.
--no-update-lock-file (thus fails on out of sync flake.lock files)nixcicachixPush and cachixUse pipeline steps
cachixPush will push the env.FLAKE_OUTPUTS built by the nix featuredockerPush pipeline stepgithubApp: provides Github integration for CI status reportingTo update the plugins, run nix-prefetch-jenkins-plugins > nix/jenkins/plugins.nix. nix-prefetch-jenkins-plugins must have been added to the devShell. See the aforementioned example.
We use sops-nix to manage secrets used by the individual CI features. Convert your SSH key (ed25519) to age, which sops uses. With macOS & 1Password, it would look like:
nix run nixpkgs#ssh-to-age <<< "$(op read 'op://Personal/id_ed25519/public key')"
nix run nixpkgs#ssh-to-age -- --private-key -i <(op read 'op://Personal/id_ed25519/actual private') > ~/.config/sops/age/keys.txt
# ^ $HOME/Library/Application\ Support/sops/age/keys.txt actually
You also want to get the host key (ssh-keyscan localhost | ssh-to-age) of the machine being deployed.
Put both these public age keys in .sops.yaml of the repository.
Nix
92.1%
Groovy
7.9%