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

Employ new documentation.nixos.extraModuleSources option #108

Merged
merged 2 commits into from
Apr 30, 2020

Conversation

bb010g
Copy link
Contributor

@bb010g bb010g commented Mar 2, 2020

Deterministic manual builds with documentation.nixos.includeAllModules! The friendly extension to the asset path is so you'll see "morph/options.nix" instead of "options.nix" when the manual mentions where morph's options are from.

Note that this depends on the option's presence in NixOS, and it probably won't be commonly available for a little while after merge (PR NixOS/nixpkgs#81557). I'm hoping for a 20.03 backport so this can be solved for the next stable.

To work around this in the meantime, a per-machine nixpkgs arg can be provided along the lines of:

let
  # for pkgs.applyPatches
  # (if you're using niv this has already been evaluated)
  bootstrapPkgs = import <nixpkgs> { };

  nixpkgsArgs = {
    config = { allowUnfree = false; };
  };
  # https://github.com/NixOS/nixpkgs/pull/81557
  nixpkgsExtraSourcesPatch = bootstrapPkgs.fetchPatch {
    url = https://github.com/NixOS/nixpkgs/commit/7535c42ebf14618e6c32577a7e2150f0cd522803.patch;
    sha256 = "0ph6xzg7j89lcjpxklhvgkvp3qmqhplhnq6p4l84b06h3krcb876";
  };
  importNixpkgs = nixpkgs: let
    nixpkgs' = bootstrapPkgs.applyPatches {
      src = nixpkgs.outPath or nixpkgs;
      patches = [ nixpkgsExtraSourcesPatch ];
    };      
  in import nixpkgs' nixpkgsArgs;
in {
  # replace <nixpkgs> with your preferred Nixpkgs source
  network.pkgs = importNixpkgs <nixpkgs>;
}

If you're already using niv, though, this can be shortened by wrapping nix/sources.nix with approximately:

let
  # ...
in sources // rec {
  pkgs = importNixpkgs sources.nixpkgs;
  # if you have a nixpkgs-unstable source:
  pkgs-unstable = importNixpkgs sources.nixpkgs-unstable;
}

and then just inheriting pkgs where desired generally (network = { inherit pkgs; }; in this particular case). This also makes sure you don't miss patching when changing Nixpkgs providers.


This change is Reviewable

This lets changes to /data/* in the `patches` attribute work.
@bb010g
Copy link
Contributor Author

bb010g commented Apr 26, 2020

Bump upon landing in 20.03.

data/eval-machines.nix Outdated Show resolved Hide resolved
Deterministic manual builds with documentation.nixos.includeAllModules!
The friendly extension to the asset path is so you'll see
"morph/options.nix" instead of "options.nix" when the manual mentions
where morph's options are from.

Note that this depends on the option's presence in NixOS:
- nixos-unstable @ 34dd64b0cc145533a935c798d5a3347d07d5d0aa
- nixos-20.03 @ 6df8f27c3915ede2101c05e1d4fbfd1828ff37a1
@bb010g bb010g changed the title Employ new documentation.nixos.extraSources option Employ new documentation.nixos.extraModuleSources option Apr 30, 2020
@bb010g
Copy link
Contributor Author

bb010g commented Apr 30, 2020

Travis failed on a missing go-bindata, but nix-build --show-trace -k -E '(import <nixos-20.03> { }).callPackage ./nix-packaging/default.nix { } succeeded just fine.

@johanot johanot merged commit c66dbfc into DBCDK:master Apr 30, 2020
@johanot
Copy link
Contributor

johanot commented Apr 30, 2020

Travis is just Travis I guess :) Thanks for the PR!

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

Successfully merging this pull request may close these issues.

None yet

2 participants