!SgYlXivkogarTVcnZO:nixos.org

Nix Flakes

874 Members
182 Servers

Load older messages


SenderMessageTime
6 Mar 2025
@solomon:cofree.coffeesolomon recurseForDerivations is a free variable 00:31:02
@solomon:cofree.coffeesolomon i now see that val.recurseForDerivations is bound via that recurse function, but that doesnt' explain how recurseForDerivations got in scope 00:31:35
@solomon:cofree.coffeesolomonor maybe i'm misunderstanding that whole statement idk00:32:19
@elikoga:matrix.orgelikogaScreenshot_20250306_013212_Firefox.png
Download Screenshot_20250306_013212_Firefox.png
00:32:25
@solomon:cofree.coffeesolomonnix lang is bonkers00:32:25
@elikoga:matrix.orgelikogaI mean it's right there00:32:30
@elikoga:matrix.orgelikogaIn the manual00:32:34
@elikoga:matrix.orgelikogaSearch nix manual00:32:41
@elikoga:matrix.orgelikogaAlso what does this have to do with flakes00:33:20
@solomon:cofree.coffeesolomonit doensn't00:33:41
@elikoga:matrix.orgelikoga flake-utils is a very pretty library but the function itself is not primarily related 00:33:54
@solomon:cofree.coffeesolomonyou showed me this code as a possible solution to a flake isuse00:33:58
@elikoga:matrix.orgelikoga Though good question on the nix build command, since I have not found documentation for the shorthand flake attribute selector 00:34:27
@solomon:cofree.coffeesolomonin any case, it didnt fix my problem00:35:04
@solomon:cofree.coffeesolomonthose nested packages still arent showing up00:35:21
@elikoga:matrix.orgelikoga Not in the root? 00:36:20
@elikoga:matrix.orgelikogaSince the tree is supposed to be flattened00:36:32
@solomon:cofree.coffeesolomon
        packages = flake-utils.lib.flattenTree {
          recurseForDerivations = true;
          docker = import ./nix/docker.nix {
            inherit pkgs;
            cofree-bot = hsPkgs.cofree-bot;
          };
          ghc982 = flake-utils.lib.flattenTree {
            recurseForDerivations = true;
            chat-bots = hsPkgs.chat-bots;
            chat-bots-contrib = hsPkgs.chat-bots-contrib;
            cofree-bot = hsPkgs.cofree-bot;
            default = hsPkgs.cofree-bot;
          };
          chat-bots = hsPkgs.chat-bots;
          chat-bots-contrib = hsPkgs.chat-bots-contrib;
          cofree-bot = hsPkgs.cofree-bot;
          default = hsPkgs.cofree-bot;
        };
00:36:36
@solomon:cofree.coffeesolomon
nix-repl> outputs.packages.x86_64-linux.
outputs.packages.x86_64-linux.chat-bots          outputs.packages.x86_64-linux.cofree-bot         outputs.packages.x86_64-linux.docker
outputs.packages.x86_64-linux.chat-bots-contrib  outputs.packages.x86_64-linux.default
00:36:54
@elikoga:matrix.orgelikoga I'm gonna stroke 00:37:14
@solomon:cofree.coffeesolomonlol00:37:21
@elikoga:matrix.orgelikoga I'm going to my laptop 00:37:25
@elikoga:matrix.orgelikoga While I'm booting think about the word "flat" 00:38:44
@solomon:cofree.coffeesolomon okay so the example from the flake-utils repo doesn't work as they demonstrate 00:42:04
@solomon:cofree.coffeesolomon
flattenTree { hello = pkgs.hello; gitAndTools = pkgs.gitAndTools }
00:42:14
@solomon:cofree.coffeesolomon
{
  hello = «derivation»;
  "gitAndTools/git" = «derivation»;
  "gitAndTools/hub" = «derivation»;
  # ...
}
00:42:21
@solomon:cofree.coffeesolomonthats from their docs00:42:26
@solomon:cofree.coffeesolomon
nix-repl> inputs.flake-utils.lib.flattenTree { hello = pkgs.hello; gitAndTools = pkgs.gitAndTools; }
{
  hello = «derivation /nix/store/aqgjk960qhww2m8hrhm6k3yacakqk7b1-hello-2.12.1.drv»;
}
00:42:37
@solomon:cofree.coffeesolomon *

This is what it actually does:

nix-repl> inputs.flake-utils.lib.flattenTree { hello = pkgs.hello; gitAndTools = pkgs.gitAndTools; }
{
  hello = «derivation /nix/store/aqgjk960qhww2m8hrhm6k3yacakqk7b1-hello-2.12.1.drv»;
}
00:42:43
@elikoga:matrix.orgelikoga
{
  description = "A very basic flake";

  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
  };

  outputs = { self, nixpkgs, flake-utils }: let 
  d = n: derivation { name = "hello${n}"; builder = "echo"; args = [ n ]; system = "x86_64-linux"; };
  in {

    packages.x86_64-linux.hello = nixpkgs.legacyPackages.x86_64-linux.hello;

    packages.x86_64-linux.default = self.packages.x86_64-linux.hello;

    skibidi1 = flake-utils.lib.flattenTree {
      toilet1 = d "1";
      toilet2 = d "2";
      toilet3 = {
        toilet1 = d "3";
        toilet3 = d "4";
        toilet4 = d "5";
        toilet5 = d "6";
      };
      toilet4 = d "7";
      toilet5 = d "8";
    };

    skibidi2 = flake-utils.lib.flattenTree {
      toilet1 = d "1";
      toilet2 = d "2";
      toilet3 = {
        recurseForDerivations = true;
        toilet1 = d "3";
        toilet3 = d "4";
        toilet4 = d "5";
        toilet5 = d "6";
      };
      toilet4 = d "7";
      toilet5 = d "8";
    };

  };
}

Gives

nix-repl> :lf .    
Added 11 variables.

nix-repl> skibidi1 
{
  toilet1 = «derivation /nix/store/vma0pz0q06k0mxyrg4hbnmjrk7fqlrcw-hello1.drv»;
  toilet2 = «derivation /nix/store/d3rqwjknbxdfsqnn55pnj1ir988ia6r0-hello2.drv»;
  toilet4 = «derivation /nix/store/6kw5bjn680zny7qrax8mjpc8p8019kyi-hello7.drv»;
  toilet5 = «derivation /nix/store/dyd47yhwwwxzx3vbdcnfzczynjq1yd83-hello8.drv»;
}

nix-repl> skibidi2 
{
  toilet1 = «derivation /nix/store/vma0pz0q06k0mxyrg4hbnmjrk7fqlrcw-hello1.drv»;
  toilet2 = «derivation /nix/store/d3rqwjknbxdfsqnn55pnj1ir988ia6r0-hello2.drv»;
  "toilet3/toilet1" = «derivation /nix/store/rvj79yklvb1yvvc5x748c2c89fqkwmxm-hello3.drv»;
  "toilet3/toilet3" = «derivation /nix/store/h04w672r5nnjlqhmzhsmcm0c7qw5s91m-hello4.drv»;
  "toilet3/toilet4" = «derivation /nix/store/szplpw5hvljsb3yx9fpdr7sa22kv177p-hello5.drv»;
  "toilet3/toilet5" = «derivation /nix/store/9pspjn694djk808nr087y86wd1a05743-hello6.drv»;
  toilet4 = «derivation /nix/store/6kw5bjn680zny7qrax8mjpc8p8019kyi-hello7.drv»;
  toilet5 = «derivation /nix/store/dyd47yhwwwxzx3vbdcnfzczynjq1yd83-hello8.drv»;
}

Does that help?

00:45:44

Show newer messages


Back to Room ListRoom Version: 6