Skip to content

Commit

Permalink
add shell.nix and nix-community's flake-compat
Browse files Browse the repository at this point in the history
- `shell.nix` allows running the package with `nix-shell --run`
- taking the version from `flake.lock` is more explicit and uniform
  • Loading branch information
fricklerhandwerk committed Feb 26, 2024
1 parent fdad590 commit c17e8bc
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 21 deletions.
25 changes: 14 additions & 11 deletions default.nix
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
# This file is the compt layer of flakes: https://github.com/edolstra/flake-compat
# See flake.nix for details
(import (
let
lock = builtins.fromJSON (builtins.readFile ./flake.lock);
in fetchTarball {
url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz";
sha256 = lock.nodes.flake-compat.locked.narHash; }
) {
src = ./.;
}).defaultNix
{ system ? builtins.currentSystem }:
let
lock = builtins.fromJSON (builtins.readFile ./flake.lock);

inherit (lock.nodes.flake-compat.locked) owner repo rev narHash;

flake-compat = fetchTarball {
url = "https://github.com/${owner}/${repo}/archive/${rev}.tar.gz";
sha256 = narHash;
};

flake = import flake-compat { inherit system; src = ./.; };
in
flake.defaultNix
11 changes: 5 additions & 6 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 1 addition & 4 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@

inputs = {
nixpkgs.url = "nixpkgs/nixos-unstable";
flake-compat = {
url = "github:edolstra/flake-compat";
flake = false;
};
flake-compat.url = "github:nix-community/flake-compat";
};

outputs = { self, nixpkgs, flake-compat }:
Expand Down
14 changes: 14 additions & 0 deletions shell.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{ system ? builtins.currentSystem }:
let
lock = builtins.fromJSON (builtins.readFile ./flake.lock);

inherit (lock.nodes.flake-compat.locked) owner repo rev narHash;

flake-compat = fetchTarball {
url = "https://github.com/${owner}/${repo}/archive/${rev}.tar.gz";
sha256 = narHash;
};

flake = import flake-compat { inherit system; src = ./.; };
in
flake.shellNix

0 comments on commit c17e8bc

Please sign in to comment.