!UKDpaKNNsBpOPfLWfX:zhaofeng.li

Colmena

280 Members
A simple, stateless NixOS deployment tool - https://github.com/zhaofengli/colmena96 Servers

You have reached the beginning of time (for this room).


SenderMessageTime
24 May 2025
@disco_stick:matrix.orgLARPing tech Simps like Hacker News users changed their display name from Mena, AR to SS Bullshit Dreams.17:25:06
@disco_stick:matrix.orgLARPing tech Simps like Hacker News users changed their display name from SS Bullshit Dreams to SSBSD.17:25:19
25 May 2025
@yuri:nekover.se@yuri:nekover.se left the room.18:33:35
27 May 2025
@agathasorceress:161.rocksAgatha Valentine Lovelace changed their profile picture.12:14:50
2 Jun 2025
@disco_stick:matrix.orgLARPing tech Simps like Hacker News users changed their display name from SSBSD to Take the I-Whatever to Desolation.01:48:04
@seanthw:matrix.orgSean Thawe joined the room.22:47:14
3 Jun 2025
@craige:mcwhirter.iocraigeDoes colmena have the capability to do a dry installation: ie: a build, a copy across but no activation. I've been going through the doco but I've not been able to see such a feature (or I've completely missed it).00:08:26
@craige:mcwhirter.iocraige

Found it. What I was looking for was:

colmena apply dry-activate
00:34:53
@deeok:matrix.orgmatrixrooms.info mod bot (does NOT read/send messages and/or invites; used for checking reported rooms) joined the room.15:34:43
4 Jun 2025
@rob.sliwi:matrix.orgrobsliwi changed their display name from Robert Sliwinski to robsliwi.18:30:22
7 Jun 2025
@deeok:matrix.orgmatrixrooms.info mod bot (does NOT read/send messages and/or invites; used for checking reported rooms) left the room.22:52:24
@deeok:matrix.orgmatrixrooms.info mod bot (does NOT read/send messages and/or invites; used for checking reported rooms) joined the room.23:44:14
9 Jun 2025
@sigmasquadron:matrix.orgSigmaSquadron joined the room.13:11:50
@disco_stick:matrix.orgLARPing tech Simps like Hacker News users changed their display name from Take the I-Whatever to Desolation to SS Bullshit Dreams.20:43:50
@ordnungswidrig-test:matrix.orgordnungswidrig joined the room.21:53:14
@ordnungswidrig-test:matrix.orgordnungswidrigRedacted or Malformed Event21:53:21
10 Jun 2025
@weriomat:matrix.orgweriomat joined the room.17:40:45
12 Jun 2025
@municipal_princess:matrix.orgmunicipal_princess joined the room.20:04:03
@municipal_princess:matrix.orgmunicipal_princess

I have started to play with colmena just now. One thing that caught my eye is, to be able to override nix.extraOptions one needs to use lib.mkDefault, else both will get written to /etc/nix/nix.conf, e.g:

defaults = { ... }: {
  nix.extraOptions = lib.mkDefault ''
      min-free = ${toString (5 * 1024 * 1024 * 1024)}
  ''
20:07:34
@zhaofeng:zhaofeng.liZhaofeng Li types.lines is really not ideal composability-wise 20:36:13
@zhaofeng:zhaofeng.liZhaofeng Li You should use the structured nix.settings instead 20:36:36
15 Jun 2025
@debtquity:matrix.orgdebtquity joined the room.14:05:14
17 Jun 2025
@khalil:ksantana.netKhalil Santana

How can I benchmark/profile what is causing colmena to be significantly slower than nixos-rebuild switch --flake? Two back-to-back executions below, no changes in between runs:

Colmena:

khalil:~/Documentos/NixOS % time colmena apply --on=andromeda
[INFO ] Using flake: git+file:///home/khalil/Documentos/NixOS
[INFO ] Enumerating nodes...
[INFO ] Selected 1 out of 4 hosts.
          ✅ 25s All done!
andromeda ✅ 19s Evaluated andromeda
andromeda ✅ 1s Built "/nix/store/yjscnkx6xy87s4z7x649dfz8b205j6nv-nixos-system-andromeda-25.
andromeda ✅ 1s Pushed system closure
andromeda ✅ 5s Activation successful                                                        
colmena apply --on=andromeda  10,13s user 5,66s system 42% cpu 37,122 total
khalil:~/Documentos/NixOS % time colmena apply --on=andromeda
[INFO ] Using flake: git+file:///home/khalil/Documentos/NixOS
[INFO ] Enumerating nodes...
[INFO ] Selected 1 out of 4 hosts.
          ✅ 25s All done!
andromeda ✅ 19s Evaluated andromeda
andromeda ✅ 1s Built "/nix/store/yjscnkx6xy87s4z7x649dfz8b205j6nv-nixos-system-andromeda-25.
andromeda ✅ 1s Pushed system closure
andromeda ✅ 5s Activation successful                                                        
colmena apply --on=andromeda  10,15s user 5,48s system 42% cpu 36,854 total
khalil:~/Documentos/NixOS % 

Nixos-rebuild switch --flake:

khalil:~/Documentos/NixOS % time nixos-rebuild switch --flake .#andromeda --target-host root@andromeda.host.ksantana.net
building the system configuration...
copying 0 paths...
Shared connection to andromeda.host.ksantana.net closed.
Shared connection to andromeda.host.ksantana.net closed.
stopping the following units: accounts-daemon.service, proc-sys-fs-binfmt_misc.automount, proc-sys-fs-binfmt_misc.mount, systemd-binfmt.service, systemd-tmpfiles-resetup.service
activating the configuration...
[agenix] creating new generation in /run/agenix.d/7
[agenix] decrypting secrets...
decrypting '/nix/store/maqzlgf99r1sf65xx2jiwzsmdm7jnzws-keepassxc.age' to '/run/agenix.d/7/keepassxc'...
decrypting '/nix/store/xlrhprsclp2l23mvm1bppsw6za819imn-restic-backup-edna.age' to '/run/agenix.d/7/restic-backup-edna'...
decrypting '/nix/store/ggr2z8ylnzl4wld7zb32nghn3qg9v82c-restic-backup-edna-remote.age' to '/run/agenix.d/7/restic-backup-edna-remote'...
decrypting '/nix/store/gp4clfixjmkhfvqmkcms6a4pb1jhxlc1-restic-backup-home-khalil.age' to '/run/agenix.d/7/restic-backup-home-khalil'...
decrypting '/nix/store/1wdan709p9lsx2jn9hzkf9sdapi20i1a-restic-backup-home-khalil-remote.age' to '/run/agenix.d/7/restic-backup-home-khalil-remote'...
decrypting '/nix/store/km4clf3936mji6b4h30yj5ccqcn1600x-tailscale.age' to '/run/agenix.d/7/tailscale'...
decrypting '/nix/store/2l8p93vz8jz4kc7z5339mrxjibpz46lj-users_khalil_passwd.age' to '/run/agenix.d/7/users_khalil_passwd'...
[agenix] symlinking new secrets to /run/agenix (generation 7)...
[agenix] removing old secrets (generation 6)...
[agenix] chowning...
setting up /etc...
reloading user units for khalil...
reloading user units for root...
restarting sysinit-reactivation.target
reloading the following units: dbus.service
restarting the following units: nix-daemon.service, polkit.service
starting the following units: accounts-daemon.service, systemd-tmpfiles-resetup.service
the following new units were started: systemd-localed.service
Shared connection to andromeda.host.ksantana.net closed.
Done. The new configuration is /nix/store/wzik0pvb0647gdnqfjlrp3j8dvm9mjh4-nixos-system-andromeda-25.11.20250527.4faa5f5
nixos-rebuild switch --flake .#andromeda --target-host   8,03s user 1,13s system 34% cpu 26,367 total
khalil:~/Documentos/NixOS % time nixos-rebuild switch --flake .#andromeda --target-host root@andromeda.host.ksantana.net
building the system configuration...
copying 0 paths...
Shared connection to andromeda.host.ksantana.net closed.
Shared connection to andromeda.host.ksantana.net closed.
activating the configuration...
[agenix] creating new generation in /run/agenix.d/8
[agenix] decrypting secrets...
decrypting '/nix/store/maqzlgf99r1sf65xx2jiwzsmdm7jnzws-keepassxc.age' to '/run/agenix.d/8/keepassxc'...
decrypting '/nix/store/xlrhprsclp2l23mvm1bppsw6za819imn-restic-backup-edna.age' to '/run/agenix.d/8/restic-backup-edna'...
decrypting '/nix/store/ggr2z8ylnzl4wld7zb32nghn3qg9v82c-restic-backup-edna-remote.age' to '/run/agenix.d/8/restic-backup-edna-remote'...
decrypting '/nix/store/gp4clfixjmkhfvqmkcms6a4pb1jhxlc1-restic-backup-home-khalil.age' to '/run/agenix.d/8/restic-backup-home-khalil'...
decrypting '/nix/store/1wdan709p9lsx2jn9hzkf9sdapi20i1a-restic-backup-home-khalil-remote.age' to '/run/agenix.d/8/restic-backup-home-khalil-remote'...
decrypting '/nix/store/km4clf3936mji6b4h30yj5ccqcn1600x-tailscale.age' to '/run/agenix.d/8/tailscale'...
decrypting '/nix/store/2l8p93vz8jz4kc7z5339mrxjibpz46lj-users_khalil_passwd.age' to '/run/agenix.d/8/users_khalil_passwd'...
[agenix] symlinking new secrets to /run/agenix (generation 8)...
[agenix] removing old secrets (generation 7)...
[agenix] chowning...
setting up /etc...
reloading user units for khalil...
reloading user units for root...
restarting sysinit-reactivation.target
Shared connection to andromeda.host.ksantana.net closed.
Done. The new configuration is /nix/store/wzik0pvb0647gdnqfjlrp3j8dvm9mjh4-nixos-system-andromeda-25.11.20250527.4faa5f5
nixos-rebuild switch --flake .#andromeda --target-host   0,12s user 0,07s system 3% cpu 4,908 total

My flake.nix:

{
  description = "KhalilSantana's NixOS configuration";

  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
    nixpkgs-staging-next.url = "path:/mnt/data/@src-code/nixpkgs";
    pre-commit-hooks.url = "github:cachix/git-hooks.nix";
    home-manager.url = "github:nix-community/home-manager";
    home-manager.inputs.nixpkgs.follows = "nixpkgs";
    nix-flatpak.url = "github:gmodena/nix-flatpak"; # unstable branch. Use github:gmodena/nix-flatpak/?ref=<tag> to pin releases.
    agenix = {
      url = "github:ryantm/agenix";
      inputs.nixpkgs.follows = "nixpkgs"; # use the same nixpkgs as the main flake
      inputs.darwin.follows = ""; # optionally choose not to download darwin deps (saves some resources on Linux)
    };
  };

  outputs =
    {
      self,
      nixpkgs,
      nixpkgs-staging-next,
      nix-flatpak,
      home-manager,
      agenix,
      pre-commit-hooks,
      ...
    }:
    let
      supportedSystems = [
        "x86_64-linux"
        "aarch64-linux"
      ];

      forAllSystems = nixpkgs.lib.genAttrs supportedSystems;

      # Common function to create a host configuration
      mkHost =
        {
          hostName,
          system,
          extraModules ? [ ],
          extraSpecialArgs ? { },
        }:
        nixpkgs.lib.nixosSystem {
          inherit system;
          modules = [
            ./hosts/${hostName}/default.nix
            agenix.nixosModules.default
            nix-flatpak.nixosModules.nix-flatpak
            home-manager.nixosModules.home-manager
            {
              home-manager = {
                useGlobalPkgs = true;
                useUserPackages = true;
                users.khalil = ./home.nix;
              };
            }
          ] ++ extraModules;
          specialArgs = {
            stagingNextPkgs = import nixpkgs-staging-next { system = "aarch64-linux"; };
          } // extraSpecialArgs;
        };

      # Common function to create a colmena host
      mkColmenaHost =
        {
          hostName,
          system,
          extraModules ? [ ],
          extraSpecialArgs ? { },
        }:
        {
          imports = [
            ./hosts/${hostName}/default.nix
            agenix.nixosModules.default
            nix-flatpak.nixosModules.nix-flatpak
            home-manager.nixosModules.home-manager
            {
              home-manager = {
                useGlobalPkgs = true;
                useUserPackages = true;
                users.khalil = ./home.nix;
              };
            }
          ] ++ extraModules;
          nixpkgs.system = system;
          deployment.targetHost = "${hostName}.host.ksantana.net";
          _module.args = {
            stagingNextPkgs = import nixpkgs-staging-next { system = "aarch64-linux"; };
          } // extraSpecialArgs;
        };

    in
    {
      formatter = forAllSystems (system: nixpkgs.legacyPackages.${system}.nixfmt-rfc-style);
      # https://github.com/cachix/git-hooks.nix
      checks = forAllSystems (
        system:
        let
          pkgs = import nixpkgs { inherit system; };
        in
        {
          pre-commit-check = pre-commit-hooks.lib.${system}.run {
            src = ./.;
            hooks = {
              nixfmt-rfc-style.enable = true;
              statix.enable = true;
              flake-checker.enable = true;
              deadnix.enable = true;
              gitleaks = {
                enable = true;
                name = "Gitleaks secrets scan";
                entry = "${pkgs.gitleaks}/bin/gitleaks git --staged --baseline-path gitleaks-report.json -v --no-color --no-banner";
                language = "system";
                pass_filenames = false;
                stages = [ "pre-commit" ];
              };
            };
          };
        }
      );

      devShells = forAllSystems (system: {
        default = nixpkgs.legacyPackages.${system}.mkShell {
          inherit (self.checks.${system}.pre-commit-check) shellHook;
          buildInputs = self.checks.${system}.pre-commit-check.enabledPackages;
        };
      });

      colmena = {
        meta = {
          nixpkgs = import nixpkgs {
            system = "x86_64-linux";
            overlays = [ ];
          };
          nodeSpecialArgs = {
            stagingNextPkgs = import nixpkgs-staging-next {
              system = "aarch64-linux";
            };
          };
        };

        "andromeda" = mkColmenaHost {
          hostName = "andromeda";
          system = "x86_64-linux";
          extraModules = [ { boot.binfmt.emulatedSystems = [ "aarch64-linux" ]; } ];
        };

        "umbrella" = mkColmenaHost {
          hostName = "umbrella";
          system = "x86_64-linux";
          extraModules = [ { boot.binfmt.emulatedSystems = [ "aarch64-linux" ]; } ];
        };

        "ocloud-ks" = mkColmenaHost {
          hostName = "ocloud-ks";
          system = "aarch64-linux";
        };

        "littlesombrero" = mkColmenaHost {
          hostName = "littlesombrero";
          system = "aarch64-linux";
        };
      };

      nixosConfigurations = {
        andromeda = mkHost {
          hostName = "andromeda";
          system = "x86_64-linux";
        };
        umbrella = mkHost {
          hostName = "umbrella";
          system = "x86_64-linux";
        };
        ocloud-ks = mkHost {
          hostName = "ocloud-ks";
          system = "aarch64-linux";
        };
        littlesombrero = mkHost {
          hostName = "littlesombrero";
          system = "aarch64-linux";
        };
      };
    };
}

(I don't feel too confortable sharing the full git repo, but I can probably produce a shallow version of it if required, with minimal sensitive info)

01:46:09
@jwagner:wdz.deJohann Wagner joined the room.07:46:25
@zhaofeng:zhaofeng.liZhaofeng Li Admittedly it's not easy to do directly, and in this specific case I think nixos-rebuild used the evaluation cache whereas Colmena cannot (you can test the raw evaluation speed by changing a file or passing --option eval-cache false to nixos-rebuild). 15:45:17
@zhaofeng:zhaofeng.liZhaofeng LiI wrote up what Colmena does to evaluate a configuration here: https://github.com/zhaofengli/colmena/issues/23515:45:22

Show newer messages


Back to Room ListRoom Version: 6