Nix: move to devshell
This commit is contained in:
parent
f91ff03006
commit
8c9f075a4e
5 changed files with 153 additions and 26 deletions
11
.envrc
11
.envrc
|
|
@ -1 +1,12 @@
|
|||
#!/usr/bin/env bash
|
||||
# ^ added for shellcheck and file-type detection
|
||||
|
||||
# Watch & reload direnv on change
|
||||
watch_file devshell.toml
|
||||
|
||||
if [[ $(type -t use_flake) != function ]]; then
|
||||
echo "ERROR: use_flake function missing."
|
||||
echo "Please update direnv to v2.30.0 or later."
|
||||
exit 1
|
||||
fi
|
||||
use flake
|
||||
23
devshell.toml
Normal file
23
devshell.toml
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
[devshell]
|
||||
name = "hugo website"
|
||||
|
||||
[[commands]]
|
||||
package = "hugo"
|
||||
|
||||
[[commands]]
|
||||
package = "go"
|
||||
|
||||
[[commands]]
|
||||
command = "hugo server"
|
||||
name = "server"
|
||||
help = "Server"
|
||||
|
||||
[[commands]]
|
||||
command = "hugo server --buildDrafts"
|
||||
name = "drafts"
|
||||
help = "Server including drafts"
|
||||
|
||||
[[commands]]
|
||||
command = "hugo"
|
||||
name = "build"
|
||||
help = "Build site – usually not necessary"
|
||||
82
flake.lock
generated
82
flake.lock
generated
|
|
@ -1,15 +1,50 @@
|
|||
{
|
||||
"nodes": {
|
||||
"flake-utils": {
|
||||
"devshell": {
|
||||
"inputs": {
|
||||
"nixpkgs": "nixpkgs",
|
||||
"systems": "systems"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1710146030,
|
||||
"narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=",
|
||||
"lastModified": 1692793255,
|
||||
"narHash": "sha256-yVyj0AE280JkccDHuG1XO9oGxN6bW8ksr/xttXcXzK0=",
|
||||
"owner": "numtide",
|
||||
"repo": "devshell",
|
||||
"rev": "2aa26972b951bc05c3632d4e5ae683cb6771a7c6",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "devshell",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-compat": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1696426674,
|
||||
"narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=",
|
||||
"owner": "edolstra",
|
||||
"repo": "flake-compat",
|
||||
"rev": "0f9255e01c2351cc7d116c072cb317785dd33b33",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "edolstra",
|
||||
"repo": "flake-compat",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-utils": {
|
||||
"inputs": {
|
||||
"systems": "systems_2"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1692799911,
|
||||
"narHash": "sha256-3eihraek4qL744EvQXsK1Ha6C3CR7nnT8X2qWap4RNk=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a",
|
||||
"rev": "f9e7cf818399d17d347f847525c5a5a8032e4e44",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
|
@ -20,11 +55,11 @@
|
|||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1711681563,
|
||||
"narHash": "sha256-rY/L4ZpFZRJDVoUsOqtpk3/8A8/l3RjYgMXmQc3uw3w=",
|
||||
"lastModified": 1677383253,
|
||||
"narHash": "sha256-UfpzWfSxkfXHnb4boXZNaKsAcUrZT9Hw+tao1oZxd08=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "9b09bde6e3fc9493b6a8b2a5702ac87c66505c64",
|
||||
"rev": "9952d6bc395f5841262b006fbace8dd7e143b634",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
|
@ -34,10 +69,26 @@
|
|||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs_2": {
|
||||
"locked": {
|
||||
"lastModified": 1693563790,
|
||||
"narHash": "sha256-qUx+8lQSCiPXbwWBwRHynHuhQT+6I7kEuDFFNQ6RSPU=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "fd8ad63083882605e8a7f659be6c9509e6e28d28",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"id": "nixpkgs",
|
||||
"type": "indirect"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"devshell": "devshell",
|
||||
"flake-compat": "flake-compat",
|
||||
"flake-utils": "flake-utils",
|
||||
"nixpkgs": "nixpkgs"
|
||||
"nixpkgs": "nixpkgs_2"
|
||||
}
|
||||
},
|
||||
"systems": {
|
||||
|
|
@ -54,6 +105,21 @@
|
|||
"repo": "default",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"systems_2": {
|
||||
"locked": {
|
||||
"lastModified": 1681028828,
|
||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"type": "github"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
|
|
|
|||
38
flake.nix
38
flake.nix
|
|
@ -1,22 +1,26 @@
|
|||
{
|
||||
description = "Hugo website";
|
||||
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
||||
description = "virtual environments";
|
||||
|
||||
inputs.devshell.url = "github:numtide/devshell";
|
||||
inputs.flake-utils.url = "github:numtide/flake-utils";
|
||||
|
||||
outputs =
|
||||
{ nixpkgs, flake-utils, ... }:
|
||||
flake-utils.lib.eachDefaultSystem (
|
||||
system:
|
||||
let
|
||||
pkgs = nixpkgs.legacyPackages.${system};
|
||||
in
|
||||
{
|
||||
devShells.default = pkgs.mkShell {
|
||||
packages = [
|
||||
pkgs.go
|
||||
pkgs.hugo
|
||||
];
|
||||
inputs.flake-compat = {
|
||||
url = "github:edolstra/flake-compat";
|
||||
flake = false;
|
||||
};
|
||||
}
|
||||
);
|
||||
|
||||
outputs = { self, flake-utils, devshell, nixpkgs, ... }:
|
||||
flake-utils.lib.eachDefaultSystem (system: {
|
||||
devShells.default =
|
||||
let
|
||||
pkgs = import nixpkgs {
|
||||
inherit system;
|
||||
|
||||
overlays = [ devshell.overlays.default ];
|
||||
};
|
||||
in
|
||||
pkgs.devshell.mkShell {
|
||||
imports = [ (pkgs.devshell.importTOML ./devshell.toml) ];
|
||||
};
|
||||
});
|
||||
}
|
||||
|
|
|
|||
23
shell.nix
Normal file
23
shell.nix
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
# Use `builtins.getFlake` if available
|
||||
if builtins ? getFlake
|
||||
then
|
||||
let
|
||||
scheme =
|
||||
if builtins.pathExists ./.git
|
||||
then "git+file"
|
||||
else "path";
|
||||
in
|
||||
(builtins.getFlake "${scheme}://${toString ./.}").devShells.${builtins.currentSystem}.default
|
||||
|
||||
# Otherwise we'll use the flake-compat shim
|
||||
else
|
||||
(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 = ./.; }
|
||||
).shellNix
|
||||
Loading…
Add table
Add a link
Reference in a new issue