!SgYlXivkogarTVcnZO:nixos.org

Nix Flakes

900 Members
184 Servers

Load older messages


SenderMessageTime
7 Dec 2023
@avaq:matrix.orgAldwin

Hi! I'm finally migrating my 6 years old nixos config to Flakes! It's mostly going well but I need some help. I used to have an overlay that added nixpkgs-unstable to the nixpkgs.unstable attribute (using fetchTarball to get it). Now, I want to use a flake input instead, and I used an inline module with an overlay to have it exposed in the same place again. I'm trying to make my existing modules compatible with the Flake, so I don't have to go in and change them all.

This all seems to work, except that Nix is refusing to evaluate Unfree packages from Unstable now. It appears as though the nixpkgs.config does not apply to the unstable input the way it used to. So my question is: How do I get this second nixpkgs input to adhere to the same config as my primary one? And by "primary" I guess I mean the one used to make the lib.nixosSystem call.

09:48:32
@avaq:matrix.orgAldwin Right now, the overlay basically does { unstable = inputs.unstable.legacyPackages.x86_64-linux; }. I'm guessing this is where I should do something to inject the parent config into the unstable nixpkgs. 09:52:49
@avaq:matrix.orgAldwin Oh. Wow. I just noticed my old approach did a similar thing: unstable = import (fetchTarball url) { config = config.nixpkgs.config; }; 09:55:45
@avaq:matrix.orgAldwin But I don't know the way to refer to the config inside a Flake 09:56:20
@petrichor:envs.net@petrichor:envs.net it's not obvious, but you can literally do unstable = import inputs.unstable { config = ... } 09:58:21
@avaq:matrix.orgAldwinOh? And then there's no need to mention the system architecture? :o09:59:03
@avaq:matrix.orgAldwin And what goes in the ...? :P Because right now I also don't know where to actually grab the parent config from 09:59:48
@avaq:matrix.orgAldwin I'm also curious about how import inputs.x works. I thought input.x is an attribute set referring to the outputs of the flake you've imported. But it's also an import path referring to the source of what you've imported?! 10:03:23
@petrichor:envs.net@petrichor:envs.net i guess if you just want to allow unfree packages you can do unstable = import inputs.unstable { config.allowUnfree = true; } 10:04:19
@petrichor:envs.net@petrichor:envs.net
In reply to @avaq:matrix.org
Oh? And then there's no need to mention the system architecture? :o
not sure, i'm still figuring out this stuff too, but i think it should work because by the time overlays are being evaluated the system is already known
10:05:09
@petrichor:envs.net@petrichor:envs.net i think your overlay could look like final: prev: { unstable = import inputs.unstable { inherit (prev) system config; } but you might get away with omitting system 10:06:59
@petrichor:envs.net@petrichor:envs.net
In reply to @avaq:matrix.org
I'm also curious about how import inputs.x works. I thought input.x is an attribute set referring to the outputs of the flake you've imported. But it's also an import path referring to the source of what you've imported?!
flakes are attribute sets with _type = "flake", but when coerced to a string (builtins.toString) or a path (builtins.toPath) they resolve to the flake's store path
10:08:18
@npc_projection:matrix.orgnpc_projectionuhh my nixpkgs needs to inherit system arch...10:09:37
@avaq:matrix.orgAldwin
In reply to @petrichor:envs.net
flakes are attribute sets with _type = "flake", but when coerced to a string (builtins.toString) or a path (builtins.toPath) they resolve to the flake's store path
Ah, okay! Clear!
10:10:40
@avaq:matrix.orgAldwin
In reply to @petrichor:envs.net
i think your overlay could look like final: prev: { unstable = import inputs.unstable { inherit (prev) system config; } but you might get away with omitting system
That's working! My system builds! :D
10:14:50
@avaq:matrix.orgAldwin Jez (he/him) ♾️: Deployed and booted the flake system. Thanks for the help :) 11:14:10
@avaq:matrix.orgAldwin * Jez (he/him) ♾️: Deployed and booted the flake systems. Thanks for the help :) 11:14:27
8 Dec 2023
@swrogers:matrix.orgShane joined the room.15:25:50
@tim:stratum0.orgdadada (they/them) removed their profile picture.19:18:59
9 Dec 2023
@softinio:matrix.orgsoftinio changed their profile picture.05:18:46
10 Dec 2023
@janik0:matrix.org@janik0:matrix.org
In reply to @janik0:matrix.org
of course, how else would I get people to do free qa :D
As promised, even so it took some time but here it is: https://discourse.nixos.org/t/announcing-nixos-dns/36702
21:47:19
11 Dec 2023
@ryoschin:matrix.org@ryoschin:matrix.org joined the room.12:49:14
@ryoschin:matrix.org@ryoschin:matrix.orgWhen using flakes to manage my system, and having `nixos-unstable` and `home-manager` as inputs, I have to call `sudo nixos-rebuild switch --flake some/path`. Now, that command sometimes downloads around 300 MB of data before actually doing the build (around 150 MB for unstable I suppose, and 148 MB for home-manager). Is it possible to avoid having to wait for that every time? I suppose it might do the downloading when I run `sudo nix-collect-garbage -d` and reboot. (Copied from NixOs, this room might be more suitable for this question)12:50:37
@janik0:matrix.org@janik0:matrix.org
In reply to @ryoschin:matrix.org
When using flakes to manage my system, and having `nixos-unstable` and `home-manager` as inputs, I have to call `sudo nixos-rebuild switch --flake some/path`. Now, that command sometimes downloads around 300 MB of data before actually doing the build (around 150 MB for unstable I suppose, and 148 MB for home-manager). Is it possible to avoid having to wait for that every time? I suppose it might do the downloading when I run `sudo nix-collect-garbage -d` and reboot. (Copied from NixOs, this room might be more suitable for this question)

you can try with --offline then it will try to run any nix * command with the local data from nix cache also stops nix shell and nix run from trying to refresh the remote nix version. Alternatively you can do:

  nix.registry = {
    nixpkgs.flake = inputs.nixpkgs;
  };

that pins any nix * command to the same flake.lock version (similar to what channels or npins or nivs would do for nix-* commands)

13:04:24
@ryoschin:matrix.org@ryoschin:matrix.org
In reply to @janik0:matrix.org

you can try with --offline then it will try to run any nix * command with the local data from nix cache also stops nix shell and nix run from trying to refresh the remote nix version. Alternatively you can do:

  nix.registry = {
    nixpkgs.flake = inputs.nixpkgs;
  };

that pins any nix * command to the same flake.lock version (similar to what channels or npins or nivs would do for nix-* commands)

But my problem is in that sudo nix-collect-garbage -d deletes the sources, and sudo nixos-rebuild switch --flake some/path has to download them again (I suppose that is because they count as cache, so it clears them). I need the gc to not clear them, and the rebuild command to download them only if there is an actual update
15:14:32
@ryoschin:matrix.org@ryoschin:matrix.org
In reply to @janik0:matrix.org

you can try with --offline then it will try to run any nix * command with the local data from nix cache also stops nix shell and nix run from trying to refresh the remote nix version. Alternatively you can do:

  nix.registry = {
    nixpkgs.flake = inputs.nixpkgs;
  };

that pins any nix * command to the same flake.lock version (similar to what channels or npins or nivs would do for nix-* commands)

* But my problem is in that sudo nix-collect-garbage -d deletes the sources, and sudo nixos-rebuild switch --flake some/path has to download them again (I suppose that is because they count as cache, so it clears them). I need the gc to not clear them, and the rebuild command to re-download them only if there is an actual update
15:14:57
@2xsaiko:tchncs.de@2xsaiko:tchncs.de
In reply to @ryoschin:matrix.org
But my problem is in that sudo nix-collect-garbage -d deletes the sources, and sudo nixos-rebuild switch --flake some/path has to download them again (I suppose that is because they count as cache, so it clears them). I need the gc to not clear them, and the rebuild command to re-download them only if there is an actual update
if you add those flakes to the local registry then they will not be collected
alternatively I guess you can add them to system.extraDependencies
15:17:08
@janik0:matrix.org@janik0:matrix.org
In reply to @ryoschin:matrix.org
But my problem is in that sudo nix-collect-garbage -d deletes the sources, and sudo nixos-rebuild switch --flake some/path has to download them again (I suppose that is because they count as cache, so it clears them). I need the gc to not clear them, and the rebuild command to re-download them only if there is an actual update
There was some setting like keepDerivations or something to prevent that but I'm not at my laptop currently.
15:17:28
@ryoschin:matrix.org@ryoschin:matrix.org
In reply to @2xsaiko:tchncs.de
if you add those flakes to the local registry then they will not be collected
alternatively I guess you can add them to system.extraDependencies
I see. Mind sharing the process?
15:55:51
@ryoschin:matrix.org@ryoschin:matrix.org
In reply to @janik0:matrix.org
There was some setting like keepDerivations or something to prevent that but I'm not at my laptop currently.
Yup, there is such an option, but I did not fully understand what it does. Does it keep all the packages I install even if they are not needed anymore, or just keep the two things I needed not to be garbage collected?
15:57:03

Show newer messages


Back to Room ListRoom Version: 6