!wfudwzqQUiJYJnqfSY:nixos.org

NixOS Module System

172 Members
36 Servers

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


SenderMessageTime
30 Aug 2024
@mr-qubo:matrix.orgmr-qubo *

I run it with nixos-rebuild -I nixos-config=$(pwd)/users-impl.nix dry-build --show-trace. ./user-impl.nix is the name of the file, contents which I pasted. You also need to put some file in ../users/ dir. I have nix.nix file with those contents:

{
  home.stateVersion = "23.11";
}

home.stateVersion is needed, otherwise there's a different error from home-manager.
And you also need <home-manager> channel (nix-channel --add https://github.com/nix-community/home-manager/archive/master.tar.gz home-manager).

16:39:46
@mr-qubo:matrix.orgmr-qubo *

I've made more minimal example:

{ lib, ... }:

let

  users = [
    {
      username = "nix";
      module = {
        home.stateVersion = "23.11";
	# MrQubo.osConfig.services.logrotate.enable = false;
      };
    }
  ];

  evalHmModule = { username, module, config, pkgs, ... }:
    (import <home-manager/modules> {
      configuration = {
        options.MrQubo = {
          osConfig.services = lib.mkOption {
            type = lib.types.raw;
          };
        };
        config = {
          submoduleSupport.enable = true;
          submoduleSupport.externalPackageInstall = false;

          home.username = config.users.users.${username}.name;
          home.homeDirectory = config.users.users.${username}.home;

          # Make activation script use same version of Nix as system as a whole.
          # This avoids problems with Nix not being in PATH.
          nix.package = config.nix.package;
        };
      };
      inherit pkgs;
    }).extendModules {
      modules = [
        {
          MrQubo.osConfig.services = config.services;
        }
        module
      ];
    };

  osConfigModules = lib.flip map users (user: { pkgs, config, ... }:
    { config.services = (evalHmModule ({ inherit pkgs config; } // user)).config.MrQubo.osConfig.services; }
  );

in {
  imports = osConfigModules;
}


# vim: sts=2 sw=2 ts=60 et:

You also need <home-manager> channel, which can be added with nix-channel --add https://github.com/nix-community/home-manager/archive/master.tar.gz home-manager.
The configuration can be run with nixos-rebuild -I nixos-config=$(pwd)/users.nix dry-build --show-trace.

16:47:04
@mr-qubo:matrix.orgmr-qubo *

I've made more minimal example:

{ lib, ... }:

let

  users = [
    {
      username = "nix";
      module = {
        home.stateVersion = "23.11";
	# MrQubo.osConfig.services.logrotate.enable = false;
      };
    }
  ];

  evalHmModule = { username, module, config, pkgs, ... }:
    (import <home-manager/modules> {
      configuration = {
        options.MrQubo = {
          osConfig.services = lib.mkOption {
            type = lib.types.raw;
          };
        };
        config = {
          submoduleSupport.enable = true;
          submoduleSupport.externalPackageInstall = false;

          home.username = config.users.users.${username}.name;
          home.homeDirectory = config.users.users.${username}.home;

          # Make activation script use same version of Nix as system as a whole.
          # This avoids problems with Nix not being in PATH.
          nix.package = config.nix.package;
        };
      };
      inherit pkgs;
    }).extendModules {
      modules = [
        {
          MrQubo.osConfig.services = config.services;
        }
        module
      ];
    };

  osConfigModules = lib.flip map users (user: { pkgs, config, ... }:
    { config.services = (evalHmModule ({ inherit pkgs config; } // user)).config.MrQubo.osConfig.services; }
  );

in {
  imports = osConfigModules;
}

You also need <home-manager> channel, which can be added with nix-channel --add https://github.com/nix-community/home-manager/archive/master.tar.gz home-manager.
The configuration can be run with nixos-rebuild -I nixos-config=$(pwd)/users.nix dry-build --show-trace.

16:47:19
@mr-qubo:matrix.orgmr-qubo *

I've made more minimal example:

users.nix:

{ lib, ... }:

let

  users = [
    {
      username = "nix";
      module = {
        home.stateVersion = "23.11";
	# MrQubo.osConfig.services.logrotate.enable = false;
      };
    }
  ];

  evalHmModule = { username, module, config, pkgs, ... }:
    (import <home-manager/modules> {
      configuration = {
        options.MrQubo = {
          osConfig.services = lib.mkOption {
            type = lib.types.raw;
          };
        };
        config = {
          submoduleSupport.enable = true;
          submoduleSupport.externalPackageInstall = false;

          home.username = config.users.users.${username}.name;
          home.homeDirectory = config.users.users.${username}.home;

          # Make activation script use same version of Nix as system as a whole.
          # This avoids problems with Nix not being in PATH.
          nix.package = config.nix.package;
        };
      };
      inherit pkgs;
    }).extendModules {
      modules = [
        {
          MrQubo.osConfig.services = config.services;
        }
        module
      ];
    };

  osConfigModules = lib.flip map users (user: { pkgs, config, ... }:
    { config.services = (evalHmModule ({ inherit pkgs config; } // user)).config.MrQubo.osConfig.services; }
  );

in {
  imports = osConfigModules;
}

You also need <home-manager> channel, which can be added with nix-channel --add https://github.com/nix-community/home-manager/archive/master.tar.gz home-manager.
The configuration can be run with nixos-rebuild -I nixos-config=$(pwd)/users.nix dry-build --show-trace.

16:47:45
3 Sep 2024
@djacu:matrix.orgdjacu left the room.23:29:30

Show newer messages


Back to Room ListRoom Version: 10