!SgYlXivkogarTVcnZO:nixos.org

Nix Flakes

895 Members
181 Servers

Load older messages


SenderMessageTime
18 Oct 2023
@petrichor:envs.net@petrichor:envs.net

i'm trying to make a flake that tangles most of its own source from a literate org-mode file at evaluation time, but to do that it needs emacs available so it needs to know what system it's being evaluated on, and builtins.currentSystem doesn't seem to be available at the point where outputs is being evaluated. hardcoding it as nixpkgs.legacyPackages.x86_64-linux.emacs works for now, but hard-coding the system there seems fragile.

is there a better way of doing this?

08:11:06
@petrichor:envs.net@petrichor:envs.net

this is what i have working:

    outputs = inputs:
      let
        pkgs = inputs.nixpkgs.legacyPackages.x86_64-linux;
        emacs = pkgs.emacsWithPackages (epkgs: [ epkgs.s epkgs.f epkgs.dash ]);
        mkSource = src: pkgs.stdenvNoCC.mkDerivation {
          name = "boxen-source";
          inherit src;

          buildPhase = ''
            ${emacs}/bin/emacs --batch --quick \
                --eval "(require 'org)" \
                --eval "(let ((org-confirm-babel-evaluate nil)) (org-babel-tangle-file \"boxen.org\"))"
          '';
          installPhase = ''
            mkdir $out
            cp -r lib packages homes modules systems files $out/
            cp boxen.org $out/
          '';
        };
        src = mkSource ./.;
      in …
08:12:14
@dunxen:x0f.orgdunxen changed their profile picture.21:16:33
19 Oct 2023
@artturin:matrix.orgArtturin
In reply to @petrichor:envs.net

this is what i have working:

    outputs = inputs:
      let
        pkgs = inputs.nixpkgs.legacyPackages.x86_64-linux;
        emacs = pkgs.emacsWithPackages (epkgs: [ epkgs.s epkgs.f epkgs.dash ]);
        mkSource = src: pkgs.stdenvNoCC.mkDerivation {
          name = "boxen-source";
          inherit src;

          buildPhase = ''
            ${emacs}/bin/emacs --batch --quick \
                --eval "(require 'org)" \
                --eval "(let ((org-confirm-babel-evaluate nil)) (org-babel-tangle-file \"boxen.org\"))"
          '';
          installPhase = ''
            mkdir $out
            cp -r lib packages homes modules systems files $out/
            cp boxen.org $out/
          '';
        };
        src = mkSource ./.;
      in …
https://github.com/numtide/flake-utils the eachX functions
09:37:18
@petrichor:envs.net@petrichor:envs.net Artturin: thanks, i'm aware of this, but i still need to then instantiate this derivation while defining the flake's outputs, which requires a specific system rather than mapping over a range of possible systems 09:52:33
@petrichor:envs.net@petrichor:envs.net i've also tried pkgs = import inputs.nixpkgs { }; for line 3, but that also errors out because builtins.currentSystem isn't available 09:54:11
@petrichor:envs.net@petrichor:envs.net i think this is because currentSystem is considered impure, and flake evaluation is pure by default: i can build this by passing --impure 09:54:47
@petrichor:envs.net@petrichor:envs.net it may be that i just can't do what i want to do without --impure because it makes the flake's outputs dependent on whichever instantiation of emacs is used 09:57:44
@petrichor:envs.net@petrichor:envs.net just trying to avoid the situation where i update the literate config and forget to regenerate the actual nix files 09:58:08
@artturin:matrix.orgArtturin
In reply to @petrichor:envs.net
Artturin: thanks, i'm aware of this, but i still need to then instantiate this derivation while defining the flake's outputs, which requires a specific system rather than mapping over a range of possible systems
https://github.com/NixOS/nix/issues/3843
10:01:24
@petrichor:envs.net@petrichor:envs.netah, this has been rumbling on for years!10:15:49
@petrichor:envs.net@petrichor:envs.net i think for now i can accept that i need to explicitly pass --impure when evaluating this flake: that's not without risk, but it does what i need to do 10:17:04
20 Oct 2023
@sheeley:matrix.org@sheeley:matrix.org joined the room.00:45:35
@ngn999:matrix.org@ngn999:matrix.org joined the room.04:49:09
21 Oct 2023
@ruination:matrix.orgPhobos changed their display name from Faust to Phobos.08:00:08
@ruination:matrix.orgPhobos changed their profile picture.08:00:10
@ruination:matrix.orgPhobos changed their profile picture.08:00:23
@thesola10:matrix.orgTheSola10 joined the room.09:50:58
@ngn999:matrix.org@ngn999:matrix.org changed their profile picture.12:45:23
@ngn999:matrix.org@ngn999:matrix.org changed their profile picture.12:46:03
@twitchy0:matrix.orgtwitchy0
In reply to @antifuchs:asf.computer
try github:pftf/RPi4/v1.35? That'll be the source tree with the tag v1.35
that worked, thanks! it doesn't have the release zip or its contents though. I just ended up using a derivation which worked
15:47:41
@antifuchs:asf.computer@antifuchs:asf.computer awesome, yeah that's the tradeoff: if you depend on a release upload, you can really only use fetchzip and such 15:48:18
@twitchy0:matrix.orgtwitchy0
In reply to @antifuchs:asf.computer
try github:pftf/RPi4/v1.35? That'll be the source tree with the tag v1.35
* that kinda worked, thanks! it doesn't have the release zip or its contents though. I just ended up using a derivation which worked
15:48:21
@rwx-rwx-rwx:matrix.orgMikael Fangel changed their display name from rwx-rwx-rwx to Mikael Fangel.17:15:37
@rwx-rwx-rwx:matrix.orgMikael Fangel set a profile picture.17:22:07
22 Oct 2023
@mokasin:mokasin.de@mokasin:mokasin.de changed their display name from Fabian to mokasin.16:12:13
@erazemk:matrix.org@erazemk:matrix.org joined the room.17:29:13
@globin:toznenetl.chatglobin joined the room.19:55:42
@janik0:matrix.org@janik0:matrix.org joined the room.21:03:21
@js:ukvly.orgJulian Stecklina (Old) joined the room.21:38:12

Show newer messages


Back to Room ListRoom Version: 6