Skip to content

Commit

Permalink
more simplification of Nix Flake
Browse files Browse the repository at this point in the history
  • Loading branch information
peterbecich committed Jun 23, 2024
1 parent 4d5aebe commit 7fd400b
Showing 1 changed file with 23 additions and 35 deletions.
58 changes: 23 additions & 35 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -15,42 +15,30 @@
inputs.flake-root.flakeModule
];
perSystem = { self', system, lib, config, pkgs, ... }: {
apps.default = {
type = "app";
program =
let
run-hackage-server = pkgs.writeShellApplication {
name = "run-hackage-server";
runtimeInputs = [ config.packages.default ];
text = ''
if [ ! -d "state" ]; then
hackage-server init --static-dir=datafiles --state-dir=state
else
echo "'state' state-dir already exists"
fi
hackage-server run \
--static-dir=datafiles \
--state-dir=state \
--base-uri=http://127.0.0.1:8080
'';
};
in "${lib.getExe run-hackage-server}";
apps.default.program = pkgs.writeShellApplication {
name = "run-hackage-server";
runtimeInputs = [ config.packages.default ];
text = ''
if [ ! -d "state" ]; then
hackage-server init --static-dir=datafiles --state-dir=state
else
echo "'state' state-dir already exists"
fi
hackage-server run \
--static-dir=datafiles \
--state-dir=state \
--base-uri=http://127.0.0.1:8080
'';
};
apps.mirror-hackage-server = {
type = "app";
program =
let
mirror-hackage-server = pkgs.writeShellApplication {
name = "mirror-hackage-server";
runtimeInputs = [ config.packages.default ];
text = ''
echo 'Copying packages from real Hackage Server into local Hackage Server.'
echo 'This assumes the local Hackage Server uses default credentials;'
echo 'otherwise, override in nix-default-servers.cfg'
hackage-mirror nix-default-servers.cfg
'';
};
in "${lib.getExe mirror-hackage-server}";
apps.mirror-hackage-server.program = pkgs.writeShellApplication {
name = "mirror-hackage-server";
runtimeInputs = [ config.packages.default ];
text = ''
echo 'Copying packages from real Hackage Server into local Hackage Server.'
echo 'This assumes the local Hackage Server uses default credentials;'
echo 'otherwise, override in nix-default-servers.cfg'
hackage-mirror nix-default-servers.cfg
'';
};
packages.default = config.packages.hackage-server;
haskellProjects.default = {
Expand Down

0 comments on commit 7fd400b

Please sign in to comment.