Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pinning nixos nixpkgs using niv in 22.05 fails? #354

Open
busti opened this issue Jun 13, 2022 · 2 comments
Open

Pinning nixos nixpkgs using niv in 22.05 fails? #354

busti opened this issue Jun 13, 2022 · 2 comments

Comments

@busti
Copy link

busti commented Jun 13, 2022

This may not be the right place to post this but I do not know where else to take this.
I have asked on discourse before but it may be a bit too obscure to get much answers.
https://discourse.nixos.org/t/rebuilding-system-using-niv-fails-in-nixos-22-05/19667/3

I used to pin my nixos nixpkgs commit when rebuilding using niv using a technique shown to me by someone at the local hackerspace about a year ago.

To do this I copied my existing systems configuration into my homedir and initialized niv in it.
I then added a file called sources-dir.nix to the nix/ folder generated by niv:

{ system ? builtins.currentSystem }:

let
  sources = import ./sources.nix {};
  pkgs = import sources.nixpkgs { inherit system; };
  lib = pkgs.lib;
in
  pkgs.runCommand "sources" {} (
    lib.concatStringsSep "\n" ([
      "mkdir $out"
    ]
      ++ lib.mapAttrsToList (name: source: "ln -s ${source.outPath} $out/${name}") sources
    )
  )

I then built the system config using the following shell script in the root dir of the config:

sources=$(nix-build nix/sources-dir.nix --no-out-link)
nixos-rebuild rebuild --target-host builduser@127.0.0.1 --use-remote-sudo -I "$sources" -I "nixos-config=$PWD/configuration.nix"

This used to work out well until the 22.05 update. Whenever I run the command now I get this very obscure error:

building Nix...
building the system configuration...
error: the string '22.05' is not allowed to refer to a store path (such as '/nix/store/0qma2xzkmp0x3j6gb0936fimvqsp297g-nixpkgs-src')

       at /nix/store/363n9qpp2aibismayc93ack9kjbs1da7-sources/nixpkgs/lib/strings.nix:562:26:

          561|   */
          562|   versionOlder = v1: v2: compareVersions v2 v1 == 1;
             |                          ^
          563|
(use '--show-trace' to show detailed location information)

Here is the same when running it with --show-trace: https://gist.github.com/busti/ca32db85512a374ae62f0a78ae921ef5

I have managed to reproduce the error in a standalone repo: https://github.com/busti/nixos-rebuild_niv-bug/blob/dev/deploy.sh

@nmattia
Copy link
Owner

nmattia commented Jun 13, 2022

That's an odd one! I'll try to find some time this week to reproduce, thanks for the report!

@busti
Copy link
Author

busti commented Jun 16, 2022

It can be reproduced using the repo I linked at the bottom of the issue post.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants