No description
  • Rust 84.1%
  • JavaScript 12.7%
  • Nix 3.2%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Patrick 686424d5a9
fix: disable SSH host key updates for prepare and deploy
Keep strict host-key verification and existing SSH configuration while
avoiding known_hosts backup hard links on cross-device mount layouts.

Assisted-by: Pi (GPT-6.1 Sol/openai, gpt-6.1-sol)
2026-11-09 14:18:06 +01:00
scripts claudius kann bischen besser js als ich 2025-05-07 12:17:42 +02:00
src fix: disable SSH host key updates for prepare and deploy 2026-11-09 14:18:06 +01:00
.envrc init 2024-11-11 17:43:58 +01:00
.gitignore feat: add remote builder capabilities 2026-03-15 16:27:50 +01:00
AGENTS.md feat: down with the claudius monoculture 2026-04-06 21:10:44 +02:00
Cargo.lock fix: disable SSH host key updates for prepare and deploy 2026-11-09 14:18:06 +01:00
Cargo.toml fix: disable SSH host key updates for prepare and deploy 2026-11-09 14:18:06 +01:00
flake.lock update 2026-03-15 17:40:29 +01:00
flake.nix update 2026-03-15 17:40:29 +01:00
README.md feat: detect login shell and switch it during deploy for prepare-home 2026-11-04 10:10:51 +01:00

nixp-meta

General purpose meta tool for all things nix.

Currently implemented modules

Build and deploy configurations

nim build and nim deploy detect configuration type from flake output name. Supported outputs are nixosConfigurations, guestConfigurations, and homeConfigurations. Duplicate names across outputs are rejected instead of choosing an implicit precedence. --minimal selects minimalConfigurations explicitly.

nim build web-server
nim build alice
nim deploy web-server@server.example.org
nim deploy alice@laptop.example.org

For Home Manager, nim builds homeConfigurations.<name>.activationPackage, copies closure through SSH as config.home.username, updates user home-manager profile, and runs activation script. In alice@laptop.example.org, alice is configuration name and laptop.example.org is SSH host or alias. If full string is configuration name, exact match wins before route parsing.

Nim passes Home Manager activation driver version 1 because nim updates user profile before activation. Version 1 tells activation script not to update profile itself; default legacy driver version 0 makes activation script create profile generation.

NixOS-only options such as --build-guests and --mode cannot be used with Home Manager configurations. Builder selection uses selected configuration's pkgs.stdenv.hostPlatform.system for both configuration types.

Prepare standalone Home Manager host

prepare-home bootstraps non-NixOS systemd Linux host before first standalone Home Manager deployment:

nim prepare-home alice@laptop.example.org --ssh-user admin
nim deploy alice@laptop.example.org

Command connects to admin@laptop.example.org, uses passwordless sudo when login is not root, and prepares evaluated Home Manager user. Omit --ssh-user to use login from local OpenSSH configuration.

Preparation:

  • creates locked user with config.home.homeDirectory;
  • installs authorized keys from nixosConfigurations.*.config.users.users.<user>.openssh.authorizedKeys;
  • installs official multi-user Nix when absent;
  • enables nix-command and flakes, adds Home Manager user to trusted-users, and starts Nix daemon;
  • enables systemd user lingering;
  • verifies key-based SSH and Nix daemon access as Home Manager user.

On NixOS hosts (detected via /etc/NIXOS or ID=nixos in /etc/os-release) it is a no-op. --dry-run prints the actions without executing them and skips Nix daemon verification. Bootstrap runs under a single non-interactive sudo invocation on the remote host, so there are no repeated password prompts.

Two optional steps are each gated behind a flag and report whether they changed anything or were already OK:

  • --apparmor writes /etc/apparmor.d/nix-bwrap and loads it so the Nix bubblewrap sandbox may create user namespaces. This works around distributions that restrict unprivileged user namespaces via AppArmor, where sandboxed builds fail with bwrap: setting up uid map: Permission denied. It skips cleanly when AppArmor or apparmor_parser is unavailable, rewrites and reloads only on change, and verifies with bwrap --unshare-user --ro-bind / / true when a bwrap is available.
  • --gpu enables non-nixos-gpu.service from Home Manager's targets.genericLinux.

The login shell is handled automatically, without a flag. The intended shell is read from the NixOS user definition (nixosConfigurations.*.config.users.users.<user>.shell); when it differs from users.defaultUserShell, prepare-home registers the corresponding ~/.nix-profile/bin/<shell> in /etc/shells and records it for the user. The actual switch happens during the next nim deploy, in the user context (no root) and only once Home Manager has installed the shell binary, so the login shell is never set to a missing path. If the NixOS configurations disagree on the shell, select one with --keys-from.

nim prepare-home alice@laptop.example.org --ssh-user admin --apparmor --gpu
nim prepare-home alice@laptop.example.org --ssh-user admin --apparmor --dry-run

Without --keys-from, all non-empty NixOS authorized-key definitions for user must agree. Select source explicitly when hosts differ:

nim prepare-home alice@laptop.example.org --ssh-user admin --keys-from web-server

Signed deployment closures can require source machine's Nix signing public key on target. Pass public key file when preparing host:

nim prepare-home alice@laptop.example.org --ssh-user admin --trusted-public-key-file ./keys/deploy.pub

File must contain Nix public signing key in NAME:BASE64 format, not SSH public key. Derive it from existing Nix secret signing key with nix key convert-secret-to-public < deploy.sec > deploy.pub. Repeat --trusted-public-key-file to trust multiple keys.

Preparation is idempotent and preserves authorized keys and Nix settings outside nim-managed blocks. It skips NixOS hosts as a no-op and rejects non-systemd hosts, interactive sudo, conflicting home directories, ambiguous key sets, and partial/nonstandard Nix installations.

Flake evaluation uses local Nix policy. Nim does not enable allow-unsafe-native-code-during-evaluation; configurations requiring it must configure it on machine running nim.

PR tracking

Using nixp-meta track <pr> on can see which nixpkgs branches a pull requests has reached, to gauge if updating is worth it yet.

Live PR diffs

If you cannot wait for a PR to be merged, or just want to test it while it's still being worked on, this module is for you.

nixp-meta add-pr <pr> Downloads the diff for the specified PR to a folder (default ./patches/PR) nixp-meta update-prs updates all prs.

Then using below module one can alter nixpkgs to use these patches

{
  inputs,
  ...
}:
{
  flake = {
    nixpkgs-patched =
      let
        system = "x86_64-linux";
        pkgs = import inputs.nixpkgs { inherit system; };
      in
      pkgs.stdenvNoCC.mkDerivation {
        name = "Nixpkgs with patches from open PRs";
        src = inputs.nixpkgs;
        dontConfigure = true;
        dontBuild = true;
        doCheck = false;
        dontFixup = true;
        installPhase = ''
          cp -r ./ $out
        '';
        patches =
          if builtins.pathExists ../patches then pkgs.lib.filesystem.listFilesRecursive ../patches else [ ];
      };
  };
}