Browse Source

Merge pull request #405 from samueldr-wip/feature/pkgs-pinning

Pin Nixpkgs (without Flakes)
consensus
Samuel Dionne-Riel 2 months ago
committed by GitHub
parent
commit
796040d35e
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 10
      default.nix
  2. 14
      doc/default.nix
  3. 5
      doc/pkgs.nix
  4. 5
      examples/demo/default.nix
  5. 5
      examples/hello/default.nix
  6. 5
      examples/target-disk-mode/default.nix
  7. 4
      examples/testing/crash-before-switch-root/default.nix
  8. 4
      examples/testing/qemu-cryptsetup/default.nix
  9. 3
      lib/eval-with-configuration.nix
  10. 3
      lib/release-tools.nix
  11. 19
      overlay/default.nix
  12. 9
      pkgs.nix
  13. 21
      release.nix
  14. 13
      shell.nix

10
default.nix

@ -1,6 +1,14 @@
{ device ? null, configuration ? null, pkgs ? null }@args:
{ device ? null
, configuration ? null
, pkgs ? (import ./pkgs.nix {})
}@args':
let
# Inherit default values correctly in `args`
args = args' // {
inherit pkgs;
};
# Selection of the configuration can by made either through NIX_PATH,
# through local.nix or as a parameter.
defaultConfiguration =

14
doc/default.nix

@ -1,6 +1,14 @@
{
pkgs ? import ./pkgs.nix
}:
{ pkgs ? import ../pkgs.nix { } }:
if pkgs == null then (builtins.throw "The `pkgs` argument needs to be provided to doc/default.nix") else
let pkgs' = pkgs; in # Break the cycle
let
pkgs = pkgs'.appendOverlays [
(final: super: {
mobile-nixos-process-doc = final.callPackage ./_support/converter {};
})
];
in
let
inherit (pkgs) stdenv mobile-nixos-process-doc rsync;

5
doc/pkgs.nix

@ -1,5 +0,0 @@
import <nixpkgs> {
overlays = [(self: super: {
mobile-nixos-process-doc = self.callPackage ./_support/converter {};
})];
}

5
examples/demo/default.nix

@ -1,4 +1,7 @@
{ device ? null, pkgs ? null }@args:
{ device ? null
, pkgs ? (import ../../pkgs.nix {})
}@args':
let args = args' // { inherit pkgs; }; in
import ../../lib/eval-with-configuration.nix (args // {
configuration = [ (import ./configuration.nix) ];

5
examples/hello/default.nix

@ -1,4 +1,7 @@
{ device ? null, pkgs ? null }@args:
{ device ? null
, pkgs ? (import ../../pkgs.nix {})
}@args':
let args = args' // { inherit pkgs; }; in
import ../../lib/eval-with-configuration.nix (args // {
configuration = [ (import ./configuration.nix) ];

5
examples/target-disk-mode/default.nix

@ -1,4 +1,7 @@
{ device ? null, pkgs ? null }@args:
{ device ? null
, pkgs ? (import ../../pkgs.nix {})
}@args':
let args = args' // { inherit pkgs; }; in
import ../../lib/eval-with-configuration.nix (args // {
configuration = [ (import ./configuration.nix) ];

4
examples/testing/crash-before-switch-root/default.nix

@ -1,4 +1,6 @@
{ pkgs ? null }@args:
{ pkgs ? (import ../../../pkgs.nix {})
}@args':
let args = args' // { inherit pkgs; }; in
let
system-build = import ../../../lib/eval-with-configuration.nix (args // {

4
examples/testing/qemu-cryptsetup/default.nix

@ -1,4 +1,6 @@
{ pkgs ? null }@args:
{ pkgs ? (import ../../../pkgs.nix {})
}@args':
let args = args' // { inherit pkgs; }; in
let
system-build = import ../../../lib/eval-with-configuration.nix (args // {

3
lib/eval-with-configuration.nix

@ -4,7 +4,7 @@
# This is meant for use internally by Mobile NixOS, the interface here
# should not be assumed to be *stable*.
{
pkgs ? import <nixpkgs> {}
pkgs ? null
# The identifier of the device this should be built for.
# (This gets massaged later on)
, device ? null
@ -13,6 +13,7 @@
, additionalConfiguration ? {}
, additionalHelpInstructions ? ""
}:
if pkgs == null then (builtins.throw "The `pkgs` argument needs to be provided to eval-with-configuration.nix") else
let
inherit (pkgs.lib) optionalString strings;
inherit (strings) concatStringsSep stringAsChars;

3
lib/release-tools.nix

@ -1,5 +1,6 @@
{ pkgs ? import <nixpkgs> {} }:
{ pkgs ? null }:
if pkgs == null then (builtins.throw "The `pkgs` argument needs to be provided to release-tools.nix") else
let
# Original `evalConfig`
evalConfig = import "${toString pkgs.path}/nixos/lib/eval-config.nix";

19
overlay/default.nix

@ -1,19 +0,0 @@
#
# Allows use of the overlay this way:
#
# ```
# $ nix-build ./overlay -A dtbTool
# $ nix-build --arg crossSystem '(import <nixpkgs/lib>).systems.examples.aarch64-multiplatform' ./overlay -A dtbTool
# ```
#
{
nixpkgs ? (fetchTarball channel:nixos-unstable)
, crossSystem ? null
}:
import nixpkgs {
inherit crossSystem;
overlays = [
(import ./overlay.nix)
(import ./mruby-builder/overlay.nix)
];
}

9
pkgs.nix

@ -0,0 +1,9 @@
let
sha256 = "sha256-M5sHgjA1OZn/c21pk64qd5kjbkBpbZuYwgaDEl9kiP8=";
rev = "5bc8b980b9178ef9a4bb622320cf34e59ea2ea10";
in
builtins.trace "(Using pinned Nixpkgs at ${rev})"
import (fetchTarball {
url = "https://github.com/NixOS/nixpkgs/archive/${rev}.tar.gz";
inherit sha256;
})

21
release.nix

@ -5,10 +5,21 @@
# instance. Though you can use it to run your builds, it is not as ergonomic as
# using `nix-build` on `./default.nix`.
#
# Also note that *by design* it still relies on NIX_PATH being used for the
# input Nixpkgs.
#
# Note:
# Verify that .ci/instantiate-all.nix lists the expected paths when adding to this file.
let
mobileReleaseTools = (import ./lib/release-tools.nix {});
# An ambiant arbitrary Nixpkgs package set.
# This is assumed to be used for e.g. Hydra evals where <nixpkgs> is an input.
# This pkgs' is used as an input to release-tools, *and* to get a `lib`.
# Named pkgs' to reduce confusion with fully evaluated `pkgs`.
pkgs' = import <nixpkgs> {};
mobileReleaseTools = (import ./lib/release-tools.nix {
pkgs = pkgs';
});
inherit (mobileReleaseTools) all-devices;
in
{ mobile-nixos ? builtins.fetchGit ./.
@ -25,8 +36,7 @@ in
let
# We require some `lib` stuff in here.
# Pick a lib from the ambient <nixpkgs>.
pkgs' = import <nixpkgs> {};
# Pick a lib from the arbitrary package set.
inherit (pkgs') lib releaseTools;
inherit (mobileReleaseTools.withPkgs pkgs')
evalFor
@ -132,10 +142,15 @@ let
{
aarch64-linux.rootfs = aarch64-eval.outputs.rootfs;
};
doc = import ./doc {
pkgs = pkgs';
};
in
rec {
inherit device;
inherit examples-demo;
inherit doc;
# Overlays build native, and cross, according to shouldEvalOn
overlay = lib.genAttrs systems (system:

13
shell.nix

@ -1,9 +1,16 @@
with (import ./overlay) {};
{ pkgs ? import ./pkgs.nix { } }:
let pkgs' = pkgs; in # Break the cycle
let
pkgs = pkgs'.appendOverlays [
(import ./overlay/overlay.nix)
];
in
# A basic shell with some tools available for porting devices.
mkShell rec {
pkgs.mkShell rec {
name = "nixos-mobile";
buildInputs = [
buildInputs = with pkgs; [
# Custom tools
mobile-nixos.autoport # Helps users kickstart their ports

Loading…
Cancel
Save