Nixify scripts using mission-control (#72)

https://github.com/Platonic-Systems/mission-control
This commit is contained in:
Sridhar Ratnakumar 2022-12-17 12:29:11 -05:00 committed by GitHub
parent 61bd08b503
commit ec7db3ca04
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 86 additions and 24 deletions

10
.vscode/tasks.json vendored
View file

@ -6,10 +6,14 @@
{ {
"label": "Ghcid", "label": "Ghcid",
"type": "shell", "type": "shell",
// You may also use bin/run-via-tmux if you have tmux
// This is useful if you often see ghost ghcid left behind by VSCode reloads. // This is useful if you often see ghost ghcid left behind by VSCode reloads.
"command": "bin/run", "command": "nix",
"args": [], "args": [
"develop",
"-c",
",",
"run"
],
"problemMatcher": [], "problemMatcher": [],
"group": { "group": {
"kind": "build", "kind": "build",

View file

@ -7,12 +7,13 @@ Get a Haskell development environment up and running quickly. Thanks to Nix, thi
- [fourmolu](https://github.com/fourmolu/fourmolu) autoformatting - [fourmolu](https://github.com/fourmolu/fourmolu) autoformatting
- [Relude](https://github.com/kowainik/relude#relude) as Prelude. - [Relude](https://github.com/kowainik/relude#relude) as Prelude.
- `.hlint.yaml` is [from relude](https://github.com/kowainik/relude/blob/main/.hlint.yaml) - `.hlint.yaml` is [from relude](https://github.com/kowainik/relude/blob/main/.hlint.yaml)
- Devshell scripts (`,` prefixed) are provided via [mission-control](https://github.com/Platonic-Systems/mission-control)
If you have an *existing* Haskell project, you should probably use https://github.com/srid/haskell-flake instead. If you have an *existing* Haskell project, you should probably use https://github.com/srid/haskell-flake instead.
## Getting Started ## Getting Started
*tldr: Install Nix, enable Flakes, open in VSCode and run `bin/run`.* *tldr: Install Nix, enable Flakes, open in VSCode and run `, run`.*
For details, see: https://srid.ca/haskell-template/start For details, see: https://srid.ca/haskell-template/start
@ -21,7 +22,7 @@ For details, see: https://srid.ca/haskell-template/start
- Run `nix flake update` to update all flake inputs. - Run `nix flake update` to update all flake inputs.
- Run `nix --option sandbox false build .#check -L` to run the flake checks. - Run `nix --option sandbox false build .#check -L` to run the flake checks.
- Run `treefmt` in nix shell to autoformat the project. This uses [treefmt](https://github.com/numtide/treefmt), which uses `./treefmt.toml` (where fourmolu and nixpkgs-fmt are specified). - Run `treefmt` in nix shell to autoformat the project. This uses [treefmt](https://github.com/numtide/treefmt), which uses `./treefmt.toml` (where fourmolu and nixpkgs-fmt are specified).
- Run `bin/hoogle` to start Hoogle with packages in your cabal file. - Run `, docs` to start Hoogle with packages in your cabal file.
- Run the application without installing: `nix run github:srid/haskell-template` (or `nix run .` from checkout) - Run the application without installing: `nix run github:srid/haskell-template` (or `nix run .` from checkout)
- Common workflows - Common workflows
- Adding library dependencies in Nix: https://srid.ca/haskell-template/dependency - Adding library dependencies in Nix: https://srid.ca/haskell-template/dependency

View file

@ -1,5 +0,0 @@
#!/usr/bin/env bash
set -xe
echo http://127.0.0.1:8888
exec nix develop -i -c hoogle serve -p 8888 --local

View file

@ -1,4 +0,0 @@
#!/usr/bin/env bash
set -xe
exec nix develop -i -c cabal -- repl

View file

@ -1,4 +0,0 @@
#!/usr/bin/env bash
set -xe
exec nix develop -i -c ghcid -c "cabal repl exe:haskell-template" --warnings -T :main

34
flake.lock generated
View file

@ -18,6 +18,21 @@
"type": "github" "type": "github"
} }
}, },
"flake-root": {
"locked": {
"lastModified": 1671295174,
"narHash": "sha256-5K+wdsB5TYSmI6HeexOMvJTZTBdXb9RbiFwXRtQkE3M=",
"owner": "srid",
"repo": "flake-root",
"rev": "bb96b89f65d7c47457303f2385798a09f4a1dd5a",
"type": "github"
},
"original": {
"owner": "srid",
"repo": "flake-root",
"type": "github"
}
},
"haskell-flake": { "haskell-flake": {
"locked": { "locked": {
"lastModified": 1668167720, "lastModified": 1668167720,
@ -33,6 +48,24 @@
"type": "github" "type": "github"
} }
}, },
"mission-control": {
"inputs": {
"flake-root": "flake-root"
},
"locked": {
"lastModified": 1671297603,
"narHash": "sha256-0fotrPbgV4WyJwh9RZ/eSWALMeAKr+n3JCQZU130BLI=",
"owner": "Platonic-Systems",
"repo": "mission-control",
"rev": "ede1ce90f17223f32ae21f2b12b8c26fd95a707e",
"type": "github"
},
"original": {
"owner": "Platonic-Systems",
"repo": "mission-control",
"type": "github"
}
},
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1670148586, "lastModified": 1670148586,
@ -71,6 +104,7 @@
"inputs": { "inputs": {
"flake-parts": "flake-parts", "flake-parts": "flake-parts",
"haskell-flake": "haskell-flake", "haskell-flake": "haskell-flake",
"mission-control": "mission-control",
"nixpkgs": "nixpkgs", "nixpkgs": "nixpkgs",
"treefmt-flake": "treefmt-flake" "treefmt-flake": "treefmt-flake"
} }

View file

@ -5,6 +5,7 @@
flake-parts.url = "github:hercules-ci/flake-parts"; flake-parts.url = "github:hercules-ci/flake-parts";
haskell-flake.url = "github:srid/haskell-flake"; haskell-flake.url = "github:srid/haskell-flake";
treefmt-flake.url = "github:srid/treefmt-flake"; treefmt-flake.url = "github:srid/treefmt-flake";
mission-control.url = "github:Platonic-Systems/mission-control";
}; };
outputs = inputs@{ self, nixpkgs, flake-parts, ... }: outputs = inputs@{ self, nixpkgs, flake-parts, ... }:
@ -13,9 +14,11 @@
imports = [ imports = [
inputs.haskell-flake.flakeModule inputs.haskell-flake.flakeModule
inputs.treefmt-flake.flakeModule inputs.treefmt-flake.flakeModule
inputs.mission-control.flakeModule
]; ];
perSystem = { self', config, pkgs, ... }: { perSystem = { self', lib, config, pkgs, ... }: {
haskellProjects.default = { # The "main" project. You can have multiple projects, but this template has only one.
haskellProjects.main = {
packages = { packages = {
haskell-template.root = ./.; haskell-template.root = ./.;
}; };
@ -34,7 +37,40 @@
cabal-fmt cabal-fmt
fourmolu; fourmolu;
}; };
packages.default = self'.packages.haskell-template; mission-control.scripts = {
docs = {
description = "Start Hoogle server for project dependencies";
command = ''
echo http://127.0.0.1:8888
hoogle serve -p 8888 --local
'';
category = "Dev Tools";
};
repl = {
description = "Start the cabal repl";
command = ''
cabal repl "$@"
'';
category = "Dev Tools";
};
fmt = {
description = "Auto-format the source tree";
command = "treefmt";
category = "Dev Tools";
};
run = {
description = "Run the project with ghcid auto-recompile";
command = ''
ghcid -c "cabal repl exe:haskell-template" --warnings -T :main
'';
category = "Primary";
};
};
packages.default = self'.packages.main-haskell-template;
devShells.default =
config.mission-control.installToDevShell config.devShells.main;
}; };
}; };
} }

View file

@ -4,4 +4,4 @@ builds:
- "*.x86_64-linux.*" - "*.x86_64-linux.*"
exclude: exclude:
# https://github.com/srid/haskell-flake/issues/21 # https://github.com/srid/haskell-flake/issues/21
- "checks.*.default-hls" - "checks.*.main-hls"

View file

@ -5,7 +5,7 @@ import Main.Utf8 qualified as Utf8
{- | {- |
Main entry point. Main entry point.
The `bin/run` script will invoke this function. The `, run` script will invoke this function.
-} -}
main :: IO () main :: IO ()
main = do main = do