diff --git a/default.nix b/default.nix index 205076c..cd03f14 100644 --- a/default.nix +++ b/default.nix @@ -6,7 +6,13 @@ # commands such as: # nix-build -A mypackage -{ pkgs ? import { } }: +{ + system ? builtins.currentSystem, + sources ? import ./sources.nix, + pkgs ? import sources.nixpkgs { + inherit system; + }, +}: { # The `lib`, `modules`, and `overlays` names are special diff --git a/sources.nix b/sources.nix new file mode 100644 index 0000000..765056e --- /dev/null +++ b/sources.nix @@ -0,0 +1,12 @@ +# Read sources from flake.lock +let + lock = builtins.fromJSON (builtins.readFile ./flake.lock); + + fetchSource = + args: + builtins.fetchTarball { + url = "https://github.com/${args.owner}/${args.repo}/archive/${args.rev}.tar.gz"; + sha256 = args.narHash; + }; +in +builtins.mapAttrs (name: value: fetchSource value.locked) lock.nodes