!UKDpaKNNsBpOPfLWfX:zhaofeng.li

Colmena

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

Load older messages


SenderMessageTime
1 Dec 2023
@mihtig:matrix.orgmihtigcurrently I get a "nix-daemon: command not found" error which seems to stem from the ssh command failing to find nix-daemon, but it's hard to track it down and I've verified that nix profile (nix.sh in ~/.nix-profile) is specified in the various .profile/.bashrc combinations09:42:29
@mihtig:matrix.orgmihtig in fact when I ssh <host> "nix-daemon --help" I get the same error - presumably this isn't colmena's fault... 09:45:06
@zhaofeng:zhaofeng.liZhaofeng LiYeah, on non-NixOS hosts the Nix binaries aren't in the PATH set up by sshd/pam. It's a long-standing issue: https://github.com/NixOS/nix/issues/107817:42:10
@cw:kernelpanic.cafeChinchilla Optional

I'm getting Failed to upload keys: I/O Error: No such file or directory (os error 2) when I try to upload keys. The key block is:

          deployment = {
            keys."myservice.secret" = {
              keyFile = /full/path/to/secrets/myservice.secret;
              uploadAt = "pre-activation";
            };
          };

Am I doing something obviously stupid? File is in the ./secrets dir by the flake, and owned by the same user

22:21:06
@cw:kernelpanic.cafeChinchilla OptionalRedacted or Malformed Event22:21:20
@cw:kernelpanic.cafeChinchilla OptionalRedacted or Malformed Event22:21:41
@cw:kernelpanic.cafeChinchilla Optional okay so remote system has that file uploaded to /run/keys/myservice.secret but with no contents in the file 22:22:39
@cw:kernelpanic.cafeChinchilla Optionalodd22:22:53
@mihtig:matrix.orgmihtig
In reply to @zhaofeng:zhaofeng.li
Yeah, on non-NixOS hosts the Nix binaries aren't in the PATH set up by sshd/pam. It's a long-standing issue: https://github.com/NixOS/nix/issues/1078
Thank you I wasn’t aware.
22:53:37
2 Dec 2023
@cw:kernelpanic.cafeChinchilla Optionaland... it works now for some reason. Didn't change anything. Great.00:31:18
@srid:matrix.org@srid:matrix.org joined the room.16:03:02
@mjolnir:nixos.orgNixOS Moderation Bot banned @srid:matrix.org@srid:matrix.org (<no reason supplied>).16:03:03
@sivertism:matrix.org@sivertism:matrix.org joined the room.16:54:22
@sivertism:matrix.org@sivertism:matrix.org

Hi! I'm new to NixOS, but want to try out Colmena as a means to set up some computers in my home. One of them is a Microsoft Surface Pro 3, which needs <nixos-hardware/microsoft/surface-pro/3> to function properly. However, I'm struggling to use that with Colmena.

What I have now is something like this:

flake.nix
machines

  • surface-configuration.nix
  • surface-hardware-configuration.nix

In flake.nix:

inputs = { nixpkg.s.url = ... };
17:27:44
@sivertism:matrix.org@sivertism:matrix.org
In reply to @sivertism:matrix.org

Hi! I'm new to NixOS, but want to try out Colmena as a means to set up some computers in my home. One of them is a Microsoft Surface Pro 3, which needs <nixos-hardware/microsoft/surface-pro/3> to function properly. However, I'm struggling to use that with Colmena.

What I have now is something like this:

flake.nix
machines

  • surface-configuration.nix
  • surface-hardware-configuration.nix

In flake.nix:

inputs = { nixpkg.s.url = ... };
hit enter too soon... hold on
17:28:12
@sivertism:matrix.org@sivertism:matrix.org *

Hi! I'm new to NixOS, but want to try out Colmena as a means to set up some computers in my home. One of them is a Microsoft Surface Pro 3, which needs <nixos-hardware/microsoft/surface-pro/3> to function properly. However, I'm struggling to use that with Colmena.

What I have now is something like this:

flake.nix
machines

  • surface-configuration.nix
  • surface-hardware-configuration.nix

In flake.nix:

inputs = { nixpkg.s.url = ... };
outputs = {nixpkgs, ...} : {
  colmena = {
    meta = // default from examples
    
  surface = {name, nodes, pkgs, ... } : {
    deployment = { targetHost = name; targetUser="nixos"; };
    networking.hostName = name;
    imports = [
      <nixos-hardware/microsoft/surface-pro/3>
      ./machines/surface-configuration.nix
    ]
  };
};

And machines/surface-configuration.nix is the /etc/nixos/configuration.nix file copied from the surface after a fresh install. It, in turn, imports machines/surface-hardware-configuration.nix, which I've also left as default.

17:34:05
@sivertism:matrix.org@sivertism:matrix.org *

Hi! I'm new to NixOS, but want to try out Colmena as a means to set up some computers in my home. One of them is a Microsoft Surface Pro 3, which needs <nixos-hardware/microsoft/surface-pro/3> to function properly. However, I'm struggling to use that with Colmena.

What I have now is something like this:

flake.nix
machines

  • surface-configuration.nix
  • surface-hardware-configuration.nix

In flake.nix:

inputs = { nixpkg.s.url = ... };
outputs = {nixpkgs, ...} : {
  colmena = {
    meta = // default from examples
    
  surface = {name, nodes, pkgs, ... } : {
    deployment = { targetHost = name; targetUser="nixos"; };
    networking.hostName = name;
    imports = [
      <nixos-hardware/microsoft/surface-pro/3>
      ./machines/surface-configuration.nix
    ]
  };
};

And machines/surface-configuration.nix is the /etc/nixos/configuration.nix file copied from the surface after a fresh install. It, in turn, imports machines/surface-hardware-configuration.nix, which I've also left as default.

From this, I first get an error error: cannot look up '<nixos-hardware/microsoft/surface-pro/3>' in pure evaluation mode (use '--impure' to override), so I use --impure, but then get error: file 'nixos-hardware/microsoft/surface-pro/3' was not found in the Nix search path (add it using $NIX_PATH or -I. I should probably add it the proper way with a url to nixos-hardware as shown in the nixos-hardware section on flakes, but I'm not sure where to stick in those modules ref: (nixos-hardware#flakes)[https://github.com/NixOS/nixos-hardware#using-nix-flakes-support].

Does anyone know how I should proceed?

17:39:11
@sivertism:matrix.org@sivertism:matrix.org
In reply to @sivertism:matrix.org

Hi! I'm new to NixOS, but want to try out Colmena as a means to set up some computers in my home. One of them is a Microsoft Surface Pro 3, which needs <nixos-hardware/microsoft/surface-pro/3> to function properly. However, I'm struggling to use that with Colmena.

What I have now is something like this:

flake.nix
machines

  • surface-configuration.nix
  • surface-hardware-configuration.nix

In flake.nix:

inputs = { nixpkg.s.url = ... };
* hit enter too soon... hold on
17:39:23
@sivertism:matrix.org@sivertism:matrix.org *

hit enter too soon... hold on

Done :)

17:39:58
@sivertism:matrix.org@sivertism:matrix.org *

Hi! I'm new to NixOS, but want to try out Colmena as a means to set up some computers in my home. One of them is a Microsoft Surface Pro 3, which needs <nixos-hardware/microsoft/surface-pro/3> to function properly. However, I'm struggling to use that with Colmena.

What I have now is something like this:

flake.nix
machines
    /surface-configuration.nix
    /surface-hardware-configuration.nix

In flake.nix:

inputs = { nixpkg.s.url = ... };
outputs = {nixpkgs, ...} : {
  colmena = {
    meta = // default from examples
    
  surface = {name, nodes, pkgs, ... } : {
    deployment = { targetHost = name; targetUser="nixos"; };
    networking.hostName = name;
    imports = [
      <nixos-hardware/microsoft/surface-pro/3>
      ./machines/surface-configuration.nix
    ]
  };
};

And machines/surface-configuration.nix is the /etc/nixos/configuration.nix file copied from the surface after a fresh install. It, in turn, imports machines/surface-hardware-configuration.nix, which I've also left as default.

From this, I first get an error error: cannot look up '<nixos-hardware/microsoft/surface-pro/3>' in pure evaluation mode (use '--impure' to override), so I use --impure, but then get error: file 'nixos-hardware/microsoft/surface-pro/3' was not found in the Nix search path (add it using $NIX_PATH or -I. I should probably add it the proper way with a url to nixos-hardware as shown in the nixos-hardware section on flakes, but I'm not sure where to stick in those modules ref: (nixos-hardware#flakes)[https://github.com/NixOS/nixos-hardware#using-nix-flakes-support].

Does anyone know how I should proceed?

17:41:05
@ibizaman:matrix.orgibizaman
In reply to @sivertism:matrix.org

Hi! I'm new to NixOS, but want to try out Colmena as a means to set up some computers in my home. One of them is a Microsoft Surface Pro 3, which needs <nixos-hardware/microsoft/surface-pro/3> to function properly. However, I'm struggling to use that with Colmena.

What I have now is something like this:

flake.nix
machines
    /surface-configuration.nix
    /surface-hardware-configuration.nix

In flake.nix:

inputs = { nixpkg.s.url = ... };
outputs = {nixpkgs, ...} : {
  colmena = {
    meta = // default from examples
    
  surface = {name, nodes, pkgs, ... } : {
    deployment = { targetHost = name; targetUser="nixos"; };
    networking.hostName = name;
    imports = [
      <nixos-hardware/microsoft/surface-pro/3>
      ./machines/surface-configuration.nix
    ]
  };
};

And machines/surface-configuration.nix is the /etc/nixos/configuration.nix file copied from the surface after a fresh install. It, in turn, imports machines/surface-hardware-configuration.nix, which I've also left as default.

From this, I first get an error error: cannot look up '<nixos-hardware/microsoft/surface-pro/3>' in pure evaluation mode (use '--impure' to override), so I use --impure, but then get error: file 'nixos-hardware/microsoft/surface-pro/3' was not found in the Nix search path (add it using $NIX_PATH or -I. I should probably add it the proper way with a url to nixos-hardware as shown in the nixos-hardware section on flakes, but I'm not sure where to stick in those modules ref: (nixos-hardware#flakes)[https://github.com/NixOS/nixos-hardware#using-nix-flakes-support].

Does anyone know how I should proceed?

I wouldn’t use the impure mode here. The syntax with brackets is not what you want with flakes. You will need to add nixos-hardware as a flake input instead.   
19:12:49
@ibizaman:matrix.orgibizaman
In reply to @sivertism:matrix.org

Hi! I'm new to NixOS, but want to try out Colmena as a means to set up some computers in my home. One of them is a Microsoft Surface Pro 3, which needs <nixos-hardware/microsoft/surface-pro/3> to function properly. However, I'm struggling to use that with Colmena.

What I have now is something like this:

flake.nix
machines
    /surface-configuration.nix
    /surface-hardware-configuration.nix

In flake.nix:

inputs = { nixpkg.s.url = ... };
outputs = {nixpkgs, ...} : {
  colmena = {
    meta = // default from examples
    
  surface = {name, nodes, pkgs, ... } : {
    deployment = { targetHost = name; targetUser="nixos"; };
    networking.hostName = name;
    imports = [
      <nixos-hardware/microsoft/surface-pro/3>
      ./machines/surface-configuration.nix
    ]
  };
};

And machines/surface-configuration.nix is the /etc/nixos/configuration.nix file copied from the surface after a fresh install. It, in turn, imports machines/surface-hardware-configuration.nix, which I've also left as default.

From this, I first get an error error: cannot look up '<nixos-hardware/microsoft/surface-pro/3>' in pure evaluation mode (use '--impure' to override), so I use --impure, but then get error: file 'nixos-hardware/microsoft/surface-pro/3' was not found in the Nix search path (add it using $NIX_PATH or -I. I should probably add it the proper way with a url to nixos-hardware as shown in the nixos-hardware section on flakes, but I'm not sure where to stick in those modules ref: (nixos-hardware#flakes)[https://github.com/NixOS/nixos-hardware#using-nix-flakes-support].

Does anyone know how I should proceed?

*

I wouldn’t use the impure mode here. The syntax with brackets is not what you want with flakes. You will need to add nixos-hardware as a flake input instead.

If that doesn’t make sense I can give a more complete example when I’m back at my computer. 

19:15:31
3 Dec 2023
@sivertism:matrix.org@sivertism:matrix.org

I was eventually able to create a flake wrapper around my existing config, which seems to work. At least nix build .#nixosConfigurations.surface.config.system.build.toplevel succeeds.

So I think it's now just about importing that into the Colmena flake? I've tried a few variations of the below colmena flake, but to no avail.

{
  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
    surface.url = "/home/sivert/work/nixos-surface";
  };
 
  outputs = {nixpkgs, surface, ...}: {
    colmena = {
      meta = {
          nixpkgs = import nixpkgs {
            system = "x86_64-linux";
          };
      };
 
      surface = { name, ...}: {
 
        deployment = {
          targetHost = "surface";
          targetUser = "nixos";
        };
        
        networking.hostName = "surface";
 
        imports = [
          surface #.nixosConfigurations.surface.config.system.build.toplevel
          ];
      };
    };
  };
}
10:19:37
@sivertism:matrix.org@sivertism:matrix.orgimage.png
Download image.png
11:25:29
@sivertism:matrix.org@sivertism:matrix.org

Turn's out the answer was (yet again) in ibizaman 's blog! https://blog.tiserbox.com/posts/2023-11-08-switch-to-colmena-for-local-deploys.html

Just had to remove the flake wrapper and set up the colmena flake like this:

{
  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
    nixos-hardware.url = "github:NixOS/nixos-hardware/master";
  };

  outputs = inputs@{nixpkgs, nixos-hardware, ...}: {
    colmena = {
      meta = {
          nixpkgs = import inputs.nixpkgs {
            system = "x86_64-linux";
          };
          specialArgs=inputs;
      };

      surface = { name, ...}: {

        deployment = {
          targetHost = "surface";
          targetUser = "nixos";
        };

        networking.hostName = "surface";

        imports = [
          inputs.nixos-hardware.nixosModules.microsoft-surface-pro-3
          ./machines/surface/configuration.nix
          ];
      };
    };
  };
}

Now I'm running into some security error though (see the above screenshot)

11:25:50
@sivertism:matrix.org@sivertism:matrix.org *

Turn's out the answer was (yet again) in ibizaman 's blog! https://blog.tiserbox.com/posts/2023-11-08-switch-to-colmena-for-local-deploys.html

Just had to remove the flake wrapper and set up the colmena flake like this:

{
  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
    nixos-hardware.url = "github:NixOS/nixos-hardware/master";
  };

  outputs = inputs@{nixpkgs, nixos-hardware, ...}: {
    colmena = {
      meta = {
          nixpkgs = import inputs.nixpkgs {
            system = "x86_64-linux";
          };
          specialArgs=inputs;
      };

      surface = { name, ...}: {

        deployment = {
          targetHost = "surface";
          targetUser = "nixos";
        };

        networking.hostName = "surface";

        imports = [
          inputs.nixos-hardware.nixosModules.microsoft-surface-pro-3
          ./machines/surface/configuration.nix
          ];
      };
    };
  };
}

Now I'm running into some security error though (see the above screenshot)
[ERROR] stderr) error: cannot add path '/nix/store/00yiiplzcqzmqaw10cghbxlb4l4xibc0-i3lock-color.pam' because it lacks a signature by a trusted key

13:08:29
@ibizaman:matrix.orgibizaman

Sivert the following is what I understand but I’m not confident in my understanding of this. I think the trusted issue is due to the user used to deploy not being root. It falls after having copied the nix derivations to the target machine when it tries to add them to the nix store. The fix should be adding that user nixos  to the nix.settings.trusted-users option.

That being said, it never worked the first time for me. I think for it to work you must first deploy a change with just the trusted-user change and then you can deploy the rest.  

15:08:37
@ibizaman:matrix.orgibizaman *

Sivert the following is what I understand but I’m not confident in my understanding of this. I think the trusted issue is due to the user used to deploy not being root. It fails after having copied the nix derivations to the target machine when it tries to add them to the nix store. The fix should be adding that user nixos  to the nix.settings.trusted-users option.

That being said, it never worked the first time for me. I think for it to work you must first deploy a change with just the trusted-user change and then you can deploy the rest.  

15:08:59
@sivertism:matrix.org@sivertism:matrix.org ibizaman: That seems to be the issue. Added nix-settings.trusted-users to the config a couple of minutes ago and it worked on my other computer. Trying it on the surface now (seems to take like 20minutes). 15:10:40
@sivertism:matrix.org@sivertism:matrix.orgSo if this works on the surface, I've got all three computers deployed from Colmena. Very cool stuff!15:12:13

Show newer messages


Back to Room ListRoom Version: 6