Skip to content

Commit

Permalink
build: tidy up the root folder a little
Browse files Browse the repository at this point in the history
  • Loading branch information
r-k-b committed Jul 27, 2024
1 parent 43f90c8 commit 217cddf
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 18 deletions.
5 changes: 2 additions & 3 deletions .envrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# https://nixos.wiki/wiki/Flakes#Direnv_integration
watch_file flake.nix
watch_file flake.lock
watch_file shell.nix
strict_env
watch_file flake.{nix,lock} nix/shell.nix

use flake
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
*.sh text eof=lf

# Tell tools that these files weren't written by hand.
nix/elm/** linguist-generated=true
9 changes: 4 additions & 5 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@
(fileset.fileFilter (file: file.hasExt "elm") ./.)
./dist
./elm.json
./registry.dat
./versions.dat
./nix/elm/registry.dat
];
};

Expand All @@ -38,7 +37,7 @@
jq . --sort-keys < ${
pkgs.writeText "elmSrcsNixFlattened.json" (builtins.toJSON
(builtins.mapAttrs (k: value: value.version)
(import ./elm-srcs.nix)))
(import ./nix/elm/elm-srcs.nix)))
} > flat-nix-deps.json
if diff flat-elm-deps.json flat-nix-deps.json; then
Expand All @@ -55,7 +54,7 @@
'';
};

elm2nix = import ./default.nix { inherit pkgs minimalElmSrc; };
elm2nix = import ./nix/default.nix { inherit pkgs minimalElmSrc; };

built = stdenv.mkDerivation {
name = "tulars";
Expand Down Expand Up @@ -99,7 +98,7 @@
};
};
checks = { inherit built failIfDepsOutOfSync; };
devShells.default = import ./shell.nix { inherit pkgs; };
devShells.default = import ./nix/shell.nix { inherit pkgs; };
apps.default = {
type = "app";
program = "${pkgs.writeScript "tularsApp" ''
Expand Down
7 changes: 4 additions & 3 deletions default.nix → nix/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@
with pkgs;

let
mkDerivation = { srcs ? ./elm-srcs.nix, src, name, srcdir ? "./src"
, targets ? [ ], registryDat ? ./registry.dat, outputJavaScript ? false }:
mkDerivation = { srcs ? ./elm/elm-srcs.nix, src, name, srcdir ? "../src"
, targets ? [ ], registryDat ? ./elm/registry.dat, outputJavaScript ? false
}:
stdenv.mkDerivation {
inherit name src;

Expand Down Expand Up @@ -43,7 +44,7 @@ let
};
in mkDerivation {
name = "tulars-elm2nix-0.1.0";
srcs = ./elm-srcs.nix;
srcs = ./elm/elm-srcs.nix;
src = minimalElmSrc;
targets = [ "Main" ];
srcdir = "./app";
Expand Down
File renamed without changes.
Binary file renamed registry.dat → nix/elm/registry.dat
Binary file not shown.
18 changes: 11 additions & 7 deletions shell.nix → nix/shell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,16 @@ let
updateElmNixDeps = pkgs.writeScriptBin "update-elm-nix-deps" ''
set -e
cd "$(git rev-parse --show-toplevel)"
elm2nix convert > elm-srcs.nix
# "Snapshot only outputs any data when redirected to the registry.dat file"
# <https://github.com/cachix/elm2nix/issues/43>
elm2nix snapshot > registry.dat
nixfmt elm-srcs.nix
echo elm-srcs.nix has been updated.
echo working in "$(realpath $PWD)"
echo creating registry snapshot at "$(realpath ./nix/elm/registry.dat)"
elm2nix snapshot
mv -f ./registry.dat ./nix/elm/registry.dat
echo "Generating Nix expressions from elm.json..."
elm2nix convert > ./nix/elm/elm-srcs.nix
nixfmt ./nix/elm/elm-srcs.nix
echo $(realpath ./nix/elm/elm-srcs.nix) has been updated.
'';
in pkgs.mkShell {
name = "tulars";
Expand All @@ -31,7 +35,7 @@ in pkgs.mkShell {
shellHook = ''
export CYPRESS_INSTALL_BINARY=0
export CYPRESS_RUN_BINARY=${pkgs.cypress}/bin/Cypress
export PATH=$PATH:${toString ./node_modules/.bin}
export PATH=$PATH:${toString ../node_modules/.bin}
echo ""
echo "This is the dev shell for the Tulars project. Coming Soon: Run 'tu --help' to see available commands."
Expand Down
Empty file removed versions.dat
Empty file.

0 comments on commit 217cddf

Please sign in to comment.