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

Regression: self.rev is absent #1503

Open
brprice opened this issue Jan 30, 2022 · 0 comments
Open

Regression: self.rev is absent #1503

brprice opened this issue Jan 30, 2022 · 0 comments

Comments

@brprice
Copy link

brprice commented Jan 30, 2022

I am using flakes with nixops, and employ the idiom

system.configurationRevision =
  if self ? rev
  then self.rev
  else throw "Refusing to build from a dirty Git tree!";

so I can trace which configuration a running deployment is using, via nixos-version --json (and enforce that every deploy corresponds to a commit).

Unfortunately this broke in the state backend rework in #1264. Now self.rev never exists, even in a clean checkout.

Reproducer:
Have a git repo with a flake.nix containing (contents are unimportant, except for testing self.rev)

{
  inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-21.11";

  outputs = { self, nixpkgs }:
{
      nixopsConfigurations.default = {
        network.description = "A server";
        network.storage.legacy.databasefile = "/tmp/state.nixops";
        nixpkgs = nixpkgs;
        serverA = {config, pkgs, ...}: {
          # let nixos-version --json know about the git revision of this flake
          system.configurationRevision =
            if self ? rev
            then self.rev
            else throw "Refusing to build from a dirty git tree!";
          fileSystems."/" = {
            device = "/dev/sda1";
            fsType = "ext3";
          };
          boot.loader.grub = {
            enable = true;
            version = 2;
            device = "/dev/sda";
          };
        };
      };
    };
}

Note that old versions of nixops work fine (this is just before #1264):

rm /tmp/state.nixops
NIXOPS_STATE=/tmp/state.nixops nix shell -L -v github:NixOS/nixops?rev=b55cbb23cc92f14b0e028ff2f8327cab4d9af5c6 -c nixops create --flake . -d serverA
NIXOPS_STATE=/tmp/state.nixops nix shell -L -v github:NixOS/nixops?rev=b55cbb23cc92f14b0e028ff2f8327cab4d9af5c6 -c nixops deploy -d serverA --build-only

However, newer versions complain that the flake is dirty -- in actuality the checkout is clean, but self.rev does not exist.
Post-#1264:

NIXOPS_STATE=/tmp/state.nixops nix shell -L -v github:NixOS/nixops?rev=9b3ac919d87db872854fb528064821b959ac38c1 -c nixops deploy -d serverA --build-only

master:

NIXOPS_STATE=/tmp/state.nixops nix shell -L -v github:NixOS/nixops?rev=ce1c57ec104636954296c229468bb65fa4ec7f8d -c nixops deploy -d serverA --build-only
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

1 participant