!UKDpaKNNsBpOPfLWfX:zhaofeng.li

Colmena

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

Load older messages


SenderMessageTime
5 Jan 2022
@zhaofeng:zhaofeng.liZhaofeng Li Change specialArgs to meta.specialArgs 21:36:53
@necrophcodr:matrix.orgnecrophcodrOh I didn't even see your reply there, so sorry!21:37:24
@necrophcodr:matrix.orgnecrophcodrWell, that does it! Thank you so much! Is this a recent change, that specialArgs are required?21:37:59
@zhaofeng:zhaofeng.liZhaofeng Li No, you need to pass it in otherwise there is no argument named home-manager 21:38:54
@necrophcodr:matrix.orgnecrophcodrThe odd thing is I've got a different system with roughly the same flake.nix setup, but for a bunch of TV settop systems. They also use home-manager in exactly the same manner, but there's no specialArgs defined there, and it still works21:39:05
@zhaofeng:zhaofeng.liZhaofeng Li Is home-manager there as part of the NixOS module arguments? That shouldn't have worked. 21:40:17
@zhaofeng:zhaofeng.liZhaofeng Li But if you put the configuration in the same file as flake.nix, then home-manager is usable from the context 21:40:47
@necrophcodr:matrix.orgnecrophcodrThe difference between the other system and this one is that this one is running NixOS, and the other is just Ubuntu with Nix slapped on top21:40:52
@zhaofeng:zhaofeng.liZhaofeng Li * But if you put the configuration in the same file as flake.nix, then home-manager is usable from the context in outputs 21:40:55
@necrophcodr:matrix.orgnecrophcodr
In reply to @zhaofeng:zhaofeng.li
Is home-manager there as part of the NixOS module arguments? That shouldn't have worked.
Yea, it is
21:41:15
@necrophcodr:matrix.orgnecrophcodr
In reply to @necrophcodr:matrix.org
Yea, it is
Well technically no, it isn't. It is, but in a different file that's imported using imports = [ ... ];
21:41:53
@necrophcodr:matrix.orgnecrophcodrIt IS running an older colmena version too21:42:24
@necrophcodr:matrix.orgnecrophcodr

It's in fact an older version of colmena as well, where I've got

meta = { inherit nixpkgs; };
21:42:28
@necrophcodr:matrix.orgnecrophcodr(The one where it magically works)21:42:40
@zhaofeng:zhaofeng.liZhaofeng LiCan you show the full config (or just the relevant parts)?21:43:28
@necrophcodr:matrix.orgnecrophcodrI'll show the relevant parts since the other system where it works is for business stuff21:44:05
@necrophcodr:matrix.orgnecrophcodr

So the flake.nix is simple:

{
  description = "NixOS Flake for NixOps deployment of dashboards";

  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-21.05";
    flake-utils.url = "github:numtide/flake-utils";
    devshell.url = "github:numtide/devshell";
    colmena.url = "github:zhaofengli/colmena";
    home-manager.url = "github:nix-community/home-manager/release-21.05";
  };

  outputs = { self, nixpkgs, flake-utils, devshell, colmena, home-manager }:
    {
      colmena = {
        meta = {
          inherit nixpkgs;
        };		# ... Nodes ...
      };
    } // flake-utils.lib.eachDefaultSystem
      (system:
        let 
          pkgs = import nixpkgs {
            inherit system;
            overlays = [ devshell.overlay ];
          };
        in
		...
}
21:45:12
@necrophcodr:matrix.orgnecrophcodrimporting of nodes using the stanndard node = import node.nix method21:45:32
@zhaofeng:zhaofeng.liZhaofeng Li Ok, what about the part where home-manager is referenced? 21:45:58
@necrophcodr:matrix.orgnecrophcodrYeah we're getting there21:46:17
@necrophcodr:matrix.orgnecrophcodr
# Edit this configuration file to define what should be installed on
# your system.  Help is available in the configuration.nix(5) man page
# and in the NixOS manual (accessible by running ‘nixos-help’).

{ config, lib, pkgs, modulesPath, ... }:
{
  deployment = {
    targetHost = "x.x.x.x";
  };
  networking.hostName = "HOST";
  home-manager.users.su = { pkgs, ... }: {
    home.file."dash.sh".source = dashFile;
  };
  imports =
    [
      ../lib/dashboard.nix
      ../lib/wifi.nix
    ];
...
}

So that's the node.nix file

21:46:28
@necrophcodr:matrix.orgnecrophcodr

And then we've got the ../lib/dashboard.nix file that contains

{ config, lib, pkgs, modulesPath, home-manager, ... }:
{
  deployment.targetUser = "su";
  imports = [
    (modulesPath + "/installer/scan/not-detected.nix")
    (home-manager + "/nixos" )
  ];
...
}
21:47:11
@necrophcodr:matrix.orgnecrophcodrAnd it just works21:47:16
@necrophcodr:matrix.orgnecrophcodr *
# Edit this configuration file to define what should be installed on
# your system.  Help is available in the configuration.nix(5) man page
# and in the NixOS manual (accessible by running ‘nixos-help’).

{ config, lib, pkgs, modulesPath, ... }:
let
  dashFile = "some_file.txt";
in
{
  deployment = {
    targetHost = "x.x.x.x";
  };
  networking.hostName = "HOST";
  home-manager.users.su = { pkgs, ... }: {
    home.file."dash.sh".source = dashFile; # dashFile is a variable declared above
  };
  imports =
    [
      ../lib/dashboard.nix
      ../lib/wifi.nix
    ];
...
}

So that's the node.nix file

21:49:56
@necrophcodr:matrix.orgnecrophcodr *
# Edit this configuration file to define what should be installed on
# your system.  Help is available in the configuration.nix(5) man page
# and in the NixOS manual (accessible by running ‘nixos-help’).

{ config, lib, pkgs, modulesPath, ... }:
let
  dashFile = ./some_file.txt;
in
{
  deployment = {
    targetHost = "x.x.x.x";
  };
  networking.hostName = "HOST";
  home-manager.users.su = { pkgs, ... }: {
    home.file."dash.sh".source = dashFile; # dashFile is a variable declared above
  };
  imports =
    [
      ../lib/dashboard.nix
      ../lib/wifi.nix
    ];
...
}

So that's the node.nix file

21:50:24
@necrophcodr:matrix.orgnecrophcodr

And from flake.lock

    "colmena": {
      "inputs": {
        "flake-compat": "flake-compat",
        "nixpkgs": "nixpkgs",
        "utils": "utils"
      },
      "locked": {
        "lastModified": 1630033162,
        "narHash": "sha256-1Vh0d2t2aSfvEXx1iQ1TRNpFfncTE3G+T0Co+dRppBo=",
        "owner": "zhaofengli",
        "repo": "colmena",
        "rev": "37b43cd6d7f924e6eb7eaa7b17852d813cf96c31",
        "type": "github"
      },
      "original": {
        "owner": "zhaofengli",
        "repo": "colmena",
        "type": "github"
      }
21:51:31
@necrophcodr:matrix.orgnecrophcodr But hey, if it worked back then accidentally and doesn't now because I wasn't doing this correctly, that is 100% on me and I can at least do things right now :D 21:52:10
@necrophcodr:matrix.orgnecrophcodrSo thank you!21:52:15
@buckley310:matrix.orgBuckleySo I'm curious. In my setup my servers all exist inside of my flake outputs.nixosConfigurations, and my outputs.colmena is just a stub that consumes nixosConfigurations and emits a colmena configuration. Is anyone else doing it this way, or just me? I really like the portability of keeping my hosts in nixosConfigurations23:27:16
@buckley310:matrix.orgBuckley

the stub:

colmena =
    { meta.nixpkgs = nixpkgs.legacyPackages."x86_64-linux"; } //
    builtins.mapAttrs
      (name: value: {
        nixpkgs.system = value.config.nixpkgs.system;
        imports = value.extraArgs.modules ++ [
          ({ config, ... }: { inherit (config.sconfig) deployment; })
        ];
      })
      (nixosConfigurations);
23:29:18

Show newer messages


Back to Room ListRoom Version: 6