Skip to content

Commit

Permalink
Setup devenv via Nix flakes (#20)
Browse files Browse the repository at this point in the history
* Setup devenv via Nix flakes

* Call pre-commit command with `-c` flag

* Call `nix develop` with `--impure` on
  • Loading branch information
sestrella authored Jan 3, 2024
1 parent 6ce536c commit adfffd9
Show file tree
Hide file tree
Showing 6 changed files with 164 additions and 34 deletions.
11 changes: 9 additions & 2 deletions .envrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
source_url "https://raw.githubusercontent.com/cachix/devenv/d1f7b48e35e6dee421cfd0f51481d17f77586997/direnvrc" "sha256-YBzqskFZxmNb3kYVoKD9ZixoPXJh1C9ZvTLGFRkauZ0="
if ! has nix_direnv_version || ! nix_direnv_version 2.2.1; then
source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/2.2.1/direnvrc" "sha256-zelF0vLbEl5uaqrfIzbgNzJWGmLzCmYAkInj/LNxvKs="
fi

use devenv
nix_direnv_watch_file flake.nix
nix_direnv_watch_file flake.lock
if ! use flake . --impure
then
echo "devenv could not be built. The devenv environment was not loaded. Make the necessary changes to devenv.nix and hit enter to try again." >&2
fi
6 changes: 1 addition & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v24
- uses: cachix/cachix-action@v13
with:
name: devenv
- run: nix-env -if https://install.devenv.sh/latest
- run: devenv ci
- run: nix develop --impure -c pre-commit run -a

test:
strategy:
Expand Down
10 changes: 0 additions & 10 deletions devenv.nix

This file was deleted.

3 changes: 0 additions & 3 deletions devenv.yaml

This file was deleted.

124 changes: 110 additions & 14 deletions devenv.lock → flake.lock

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

44 changes: 44 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.05";
systems.url = "github:nix-systems/default";
devenv.url = "github:cachix/devenv";
};

nixConfig = {
extra-trusted-public-keys = "devenv.cachix.org-1:w1cLUi8dv3hnoSPGAuibQv+f9TZLr6cv/Hm9XgU50cw=";
extra-substituters = "https://devenv.cachix.org";
};

outputs = { self, nixpkgs, devenv, systems, ... } @ inputs:
let
forEachSystem = nixpkgs.lib.genAttrs (import systems);
in
{
packages = forEachSystem (system: {
devenv-up = self.devShells.${system}.default.config.procfileScript;
});

devShells = forEachSystem
(system:
let
pkgs = nixpkgs.legacyPackages.${system};
in
{
default = devenv.lib.mkShell {
inherit inputs pkgs;
modules = [
{
# https://devenv.sh/reference/options/
languages.javascript.enable = true;

pre-commit.hooks = {
shellcheck.enable = true;
shfmt.enable = true;
};
}
];
};
});
};
}

0 comments on commit adfffd9

Please sign in to comment.