!UKDpaKNNsBpOPfLWfX:zhaofeng.li

Colmena

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

Load older messages


SenderMessageTime
5 Jan 2022
@andi:kack.itandi- joined the room.16:12:32
@zhaofeng:zhaofeng.liZhaofeng LiWhat does your hive.nix look like?17:09:20
@necrophcodr:matrix.orgnecrophcodr
In reply to @zhaofeng:zhaofeng.li
What does your hive.nix look like?

Sorry for not replying earlier, but I don't have a hive.nix, just a flake.nix as follows:

{
  description = "Flake for RPI 4 Lab Infrastructure";

  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-21.05";
    devshell.url = "github:numtide/devshell";
    flake-utils.url = "github:numtide/flake-utils";
    colmena.url = "github:zhaofengli/colmena/v0.2.0";
    colmena.inputs.utils.follows = "flake-utils";
    home-manager.url = "github:nix-community/home-manager/release-21.05";
    home-manager.inputs.nixpkgs.follows = "nixpkgs";
  };
  outputs = { self, nixpkgs, devshell, flake-utils, colmena, home-manager }:
    let
      nativePkgs = import nixpkgs { 
        system = ( if builtins ? currentSystem then builtins.currentSystem else "x86_64-linux" );
        };
    in
    {
      colmena = {
        meta.nixpkgs = nativePkgs;
        pi = import ./pi4.nix;
        specialArgs = {
          inherit home-manager;
        };
      };
    } // flake-utils.lib.eachDefaultSystem
      (system:
        let 
          pkgs = import nixpkgs { inherit system; overlays = [ devshell.overlay ]; };
        in
        {
          devShell = pkgs.devshell.mkShell {
            packages = with pkgs; [
              colmena.defaultPackage.${system}
            ];
          };
        }
      );
}

21:35:33
@zhaofeng:zhaofeng.liZhaofeng LiThat confirms my suspicions in https://matrix.to/#/!KqkRjyTEzAGRiZFBYT:nixos.org/$YU9o4IlsSyfFcrRGby4AGBIvMLhMH0OPdWvEG4-5Qnk?via=nixos.org&via=matrix.org&via=tchncs.de21:36:44
@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

There are no newer messages yet.


Back to Room ListRoom Version: 6