1
0
Files
universal-calculator/flake.nix

182 lines
12 KiB
Nix

{
description = ''
A basic Haskell flake for solving problems and sketching out concepts.
https://tristancacqueray.github.io/blog/beautiful-haskell
'';
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
flake-parts.url = "github:hercules-ci/flake-parts";
git-hooks-nix.url = "github:cachix/git-hooks.nix";
git-hooks-nix.inputs.nixpkgs.follows = "nixpkgs";
treefmt-nix.url = "github:numtide/treefmt-nix";
treefmt-nix.inputs.nixpkgs.follows = "nixpkgs";
};
outputs = inputs @ {flake-parts, ...}:
flake-parts.lib.mkFlake {inherit inputs;} {
imports = [
# To import a flake module
# 1. Add foo to inputs
# 2. Add foo as a parameter to the outputs function
# 3. Add here: foo.flakeModule
inputs.git-hooks-nix.flakeModule
inputs.treefmt-nix.flakeModule
];
systems = [
"x86_64-linux"
# "aarch64-linux"
# "aarch64-darwin"
# "x86_64-darwin"
];
flake = {
# The usual flake attributes can be defined here, including system-
# agnostic ones like nixosModule and system-enumerating ones, although
# those are more easily expressed in perSystem.
};
perSystem = {
config,
self',
inputs',
pkgs,
system,
...
}: {
# Per-system attributes can be defined here. The self' and inputs'
# module parameters provide easy access to attributes of the same
# system.
# Equivalent to inputs'.nixpkgs.legacyPackages.hello;
# packages.default = pkgs.hello;
devShells.default = let
# https://downloads.haskell.org/~ghc/9.10.3/docs/users_guide/index.html
ghc' = pkgs.haskell.packages.ghc9103.ghcWithHoogle (
self:
with self; [
relude
split
aeson
random
neat-interpolation
# maths
primes
arithmoi
parallel
# graphing libraries!
Chart
Chart-cairo
]
);
clean = pkgs.writeShellScriptBin "clean" ''
# Delete executables
find . -type f -executable -not -path '*/.git/*' -delete
# Delete all Haskell IR files
find . -type f -name '*.hi' -delete
find . -type f -name '*.o' -delete
# Delete any test graphs created
find . -type f -name '*.png' -delete
'';
in
pkgs.mkShell {
packages = with pkgs; [
cowsay
alejandra
ghc'
clean
haskell-language-server
ghcid
hlint
kotlin
];
shellHook = ''
${config.pre-commit.installationScript}
echo ".------..------..------..------..------..------..------..------..------..------."
echo "|U.--. ||N.--. ||I.--. ||V.--. ||E.--. ||R.--. ||S.--. ||A.--. ||L.--. ||=.--. |"
echo "| (\/) || :(): || (\/) || :(): || (\/) || :(): || :/\: || (\/) || :/\: || (\/) |"
echo "| :\/: || ()() || :\/: || ()() || :\/: || ()() || :\/: || :\/: || (__) || :\/: |"
echo "| '--'U|| '--'N|| '--'I|| '--'V|| '--'E|| '--'R|| '--'S|| '--'A|| '--'L|| '--'=|"
echo "[------'[------'[------'[------'[------'[------'[------'[------'[------'[------'"
echo ".------..------..------..------..------..------..------..------..------..------."
echo "|C.--. ||A.--. ||L.--. ||C.--. ||U.--. ||L.--. ||A.--. ||T.--. ||O.--. ||R.--. |"
echo "| :/\: || (\/) || :/\: || :/\: || (\/) || :/\: || (\/) || :/\: || :/\: || :(): |"
echo "| :\/: || :\/: || (__) || :\/: || :\/: || (__) || :\/: || (__) || :\/: || ()() |"
echo "| '--'C|| '--'A|| '--'L|| '--'C|| '--'U|| '--'L|| '--'A|| '--'T|| '--'O|| '--'R|"
echo "[------'[------'[------'[------'[------'[------'[------'[------'[------'[------'"
echo " _ _ _ _ "
echo "| | | | (_) | | ______ "
echo "| | | | _ __ _ __ __ ___ _ __ ___ __ _ | ||______|"
echo "| | | || '_ \ | |\ \ / / / _ \| '__|/ __| / _[ || | ______ "
echo "| |_| || | | || | \ V / | __/| | \__ \| (_| || ||______|"
echo " \___/ |_| |_||_| \_/ \___||_| |___/ \__,_||_| "
echo " "
echo " "
echo " _____ _ _ _ "
echo "/ __ \ | | | | | | "
echo "| / \/ __ _ | | ___ _ _ | | __ _ | |_ ___ _ __ "
echo "| | / _[ || | / __|| | | || | / _[ || __| / _ \ | '__| "
echo "| \__/\| (_| || || (__ | |_| || || (_| || |_ | (_) || | "
echo " \____/ \__,_||_| \___| \__,_||_| \__,_| \__| \___/ |_| "
'';
};
pre-commit = {
settings.hooks = {
alejandra.enable = true;
mdformat.enable = true;
prettier.enable = true;
prettier.excludes = [".*\.md" "flake.lock"];
stylish-haskell.enable = true;
};
};
treefmt = {
programs = {
alejandra.enable = true;
mdformat.enable = true;
prettier.enable = true;
prettier.excludes = ["*.md"];
stylish-haskell.enable = true;
};
};
};
};
}