andir / npins

Nix dependency pinning. Very similar to Niv but has a few features that I personally wanted.
European Union Public License 1.2
180 stars 14 forks source link

Nix channel pins and improvements #22

Closed piegamesde closed 2 years ago

piegamesde commented 2 years ago

Closes #18

andir commented 2 years ago
[nix-shell:/tmp/demo]$ npins --help
npins 0.1.0

USAGE:
    npins [OPTIONS] <SUBCOMMAND>

FLAGS:
    -h, --help       Prints help information
    -V, --version    Prints version information

OPTIONS:
    -d, --directory <folder>    Base folder for sources.json and the boilerplate default.nix [env: NPINS_DIRECTORY=]
                                [default: npins]

SUBCOMMANDS:
    add           Adds a new pin entry
    fetch         Query some release information and then print out the entry
    help          Prints this message or the help of the given subcommand(s)
    import-niv    Try to import entries from Niv
    init          Intializes the npins directory. Running this multiple times will restore/upgrade the `default.nix`
                  and never touch your sources.json
    remove        Removes one pin entry
    show          Lists the current pin entries
    update        Updates all or the given pin to the latest version
    upgrade       Upgrade the sources.json and default.nix to the latest format version. This may occasionally break
                  Nix evaluation!

[nix-shell:/tmp/demo]$ npins init --help
npins-init 0.1.0
Intializes the npins directory. Running this multiple times will restore/upgrade the `default.nix` and never touch your
sources.json

USAGE:
    npins init [FLAGS] [OPTIONS]

FLAGS:
        --bare    Don't add an initial `nixpkgs` entry
    -h, --help    Prints help information

OPTIONS:
    -d, --directory <folder>    Base folder for sources.json and the boilerplate default.nix [env: NPINS_DIRECTORY=]
                                [default: npins]

[nix-shell:/tmp/demo]$ npins init --bare
[INFO ] Welcome to npins!
[INFO ] Creating `npins` directory
[INFO ] Writing default.nix
[INFO ] Writing initial sources.json (empty)
[INFO ] Done.

[nix-shell:/tmp/demo]$ npins add channel nixos-21.11

[nix-shell:/tmp/demo]$ nix repl
warning: unknown setting 'experimental-features'
Welcome to Nix version 2.3.16. Type :? for help.

nix-repl> pins = import ./npins

nix-repl> pkgs = import pins."nixos-21.11" { }

[20.4 MiB DL]
error: hash mismatch in file downloaded from 'https://releases.nixos.org/nixos/21.11/nixos-21.11.335820.521e4d7d13b/nixexprs.tar.xz':
  wanted: sha256:16p4cxpzlwdj6pv29a2dd0cv439v0dwlddzkdh1wnv7075nw2lyh
  got:    sha256:1d79qhyqa1h58y6k7gacm72is8hpla8db3sbqpkq6g813r8sdlym

Two remarks:

  1. The npins add channel ... command doesn't log anything but hangs there for a few seconds.
  2. The hash doesn't match :D
piegamesde commented 2 years ago
  1. Yes, I moved the logging commit to the other PR
  2. I cannot reproduce the hash mismatch. I tried it twice and it works for me :D
mweinelt commented 2 years ago
❯ nix-prefetch-url --unpack https://releases.nixos.org/nixos/21.11/nixos-21.11.335820.521e4d7d13b/nixexprs.tar.xz
path is '/nix/store/01j26k9mn7kyk5k16qjjigw3gwsi86az-nixexprs.tar.xz'
16p4cxpzlwdj6pv29a2dd0cv439v0dwlddzkdh1wnv7075nw2lyh