!SgYlXivkogarTVcnZO:nixos.org

Nix Flakes

756 Members
149 Servers

Load older messages


SenderMessageTime
7 May 2025
@hexa:lossy.networkhexa but ideally I could just nix build .#tests 20:58:26
@hexa:lossy.networkhexawithout having to select an individual test20:58:37
@skyesoss:matrix.org@skyesoss:matrix.org left the room.20:58:40
@hexa:lossy.networkhexabut with the option to20:58:41
@hexa:lossy.networkhexabut e.g. package attributes can only be derivations or paths20:59:37
@sandro:supersandro.deSandro 🐧create a dummy derivation tests which just draws in everything21:26:36
@christopherg98:matrix.orgchristopherg98 joined the room.22:33:07
8 May 2025
@mr.defenestrator:matrix.orgMr. DefenestratorIt'd be cool if --argstr worked with flake checks. I just did a little test and it failed because my arg wasn't defined in _module.args -- I didn't think checks relied in the module system, but that's kind of interesting if they do. Maybe someone who knows more about the checks attribute could confirm that. Parameterizing checks could be useful.04:36:15
@dramforever:matrix.orgdramforeverflake checks don't inherently use the module system as they're just derivations. do you use something like flake-parts?07:29:57
@dramforever:matrix.orgdramforever like, just to be clear it is not an exaggeration that the nix cli has zero knowledge of how nixos modules work 07:30:20
@isabel:isabelroses.comisabel changed their profile picture.08:58:19
@kdobieder:matrix.orgkdobiederDoes anyone have an example of a Home Manager module shared via Flake? In the consuming flakes, I’d like it to be added directly to homeManagerModule.modules. The Home Manager module should be able to install packages from nixpkgs.10:50:41
@kdobieder:matrix.orgkdobieder * Does anyone have an example of a Home Manager module shared via Flake? In the consuming flakes, I’d like it to be added directly to homeManagerModule.modules. The Home Manager module should be able to install packages from nixpkgs. 10:51:05
@dramforever:matrix.orgdramforever

The Home Manager module should be able to install packages from nixpkgs.
pkgs

10:54:50
@dramforever:matrix.orgdramforever *

The Home Manager module should be able to install packages from nixpkgs.

use pkgs

10:54:55
@kdobieder:matrix.orgkdobieder

Well I'd like to pass some things to the flake and this is what I came up with:

{
  description = "Custom Flake";

  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs/nixos-24.11";
    nixpkgs-unstable.url = "github:nixos/nixpkgs/nixos-unstable";
    myvendor-scripts.url = "git+https://git.myvendor.de/linux/scripts";
  };

  outputs = { nixpkgs, nixpkgs-unstable, myvendor-scripts, ... }: let
    getModule = {system, flakefolder}: let
      homeManagerModule = import ./modules {
        lib = nixpkgs.lib;
        pkgs = nixpkgs.legacyPackages.${system};
        pkgs-unstable = nixpkgs-unstable.legacyPackages.${system};
        flakefolder = flakefolder;
        myvendor-scripts = myvendor-scripts;
      };
    in {
      home-manager = homeManagerModule ;
    };
  in {
    getModule = getModule;
  };
}

But this way I have to define everything a would need - like lib, config, etc. Doesn't seem to be a good solution. Am I missing something?

10:57:18
@kdobieder:matrix.orgkdobieder *

Well I'd like to pass some things to the flake and this is what I came up with:

{
  description = "Custom Flake";

  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs/nixos-24.11";
    nixpkgs-unstable.url = "github:nixos/nixpkgs/nixos-unstable";
    myvendor-scripts.url = "git+https://git.myvendor.de/linux/scripts";
  };

  outputs = { nixpkgs, nixpkgs-unstable, myvendor-scripts, ... }: let
    getModule = {system, flakefolder}: let
      homeManagerModule = import ./modules {
        lib = nixpkgs.lib;
        pkgs = nixpkgs.legacyPackages.${system};
        pkgs-unstable = nixpkgs-unstable.legacyPackages.${system};
        flakefolder = flakefolder;
        myvendor-scripts = myvendor-scripts;
      };
    in {
      home-manager = homeManagerModule ;
    };
  in {
    getModule = getModule;
  };
}

But this way I have to define everything a module would need - like lib, config, etc. Doesn't seem to be a good solution. Am I missing something?

10:58:08
@dramforever:matrix.orgdramforever just don't pass it lib, config, etc 11:27:18
@dramforever:matrix.orgdramforevermodules are supposed to be a function11:27:30
@dramforever:matrix.orgdramforeverideally, module inputs can be set through options11:29:09
@kdobieder:matrix.orgkdobiederHow would that be done? 11:29:44
@dramforever:matrix.orgdramforeverhttps://nixos.org/manual/nixos/stable/#sec-writing-modules11:31:35
@kdobieder:matrix.orgkdobiederI don't see how that mentions passing options from a consuming flake to an imported home manager module.11:33:47
@dramforever:matrix.orgdramforeverthere is no mention of that because that has nothing to do with flakes11:34:20
@dramforever:matrix.orgdramforever

when you have something like in a "consuming flake"

      homeConfigurations.dram = home-manager.lib.homeManagerConfiguration {
        ...
        modules = [
          foo
          bar
          ./home.nix
        ];
      };

all three modules are on equal footing, they can each have options and config, and any one module can set the values of options defined in any module

11:36:12
@dramforever:matrix.orgdramforever *

when you have something like in a "consuming flake"

      homeConfigurations.dram = home-manager.lib.homeManagerConfiguration {
        ...
        modules = [
          foo
          bar
          ./home.nix
        ];
      };

all three modules are on equal footing, they can each have options and config, and any module can set the values of options defined in any module

11:36:25
@dramforever:matrix.orgdramforever do note that you can't have the value of an option affect the definition of options themselves (so, in short, no using config in imports or options) 11:37:20
@kdobieder:matrix.orgkdobieder Okay, I see. The problem I have is that I want to pass a custom variable to bar for example. 11:37:33
@dramforever:matrix.orgdramforeverthat would be a cyclic dependency11:37:35
@dramforever:matrix.orgdramforeverwhat is the argument used for?11:38:32

Show newer messages


Back to Room ListRoom Version: 6