dev/flake.nix

182 lines
5 KiB
Nix

{
description = "All things development";
inputs.flake-parts.url = "github:hercules-ci/flake-parts";
inputs.nixpkgs.url = "github:NixOS/nixpkgs?ref=nixpkgs-unstable";
inputs.pre-commit-hooks-nix.url = "github:cachix/pre-commit-hooks.nix";
inputs.treefmt-nix.url = "github:numtide/treefmt-nix";
nixConfig = {
nix = ["http://cache.home"];
};
outputs = inputs @ {
flake-parts,
pre-commit-hooks-nix,
treefmt-nix,
self,
...
}:
flake-parts.lib.mkFlake {inherit inputs;} {
imports = [
treefmt-nix.flakeModule
pre-commit-hooks-nix.flakeModule
];
systems = ["x86_64-linux"];
perSystem = {
config,
self',
pkgs,
lib,
...
}: let
mdpls = let
version = "30761508593d85b5743ae39c4209947740eec92d";
in
pkgs.rustPlatform.buildRustPackage {
inherit version;
pname = "mdpls";
src = pkgs.fetchFromGitHub {
owner = "euclio";
repo = "mdpls";
rev = version;
sha256 = "sha256-4n1MX8hS7JmKzaL8GfMq2q3IdwE4fvMmWOYo7rY+cdY=";
};
cargoSha256 = "sha256-J49A43BSCJGqaY7AX7XsoMwy6sgyaIx2Vz57Z1cFItc=";
};
packagesSharedByAll = with pkgs; [
diff-so-fancy
pre-commit
];
scripts = {
beste-schule-set-missing-grades = pkgs.writeShellApplication {
name = "set-missing-grades";
runtimeInputs = [
pkgs.coreutils
pkgs.jq
pkgs.curl
];
text = builtins.readFile ./scripts/set-missing-grades.sh;
};
};
shells = {
nix = {
name = "generic nix";
packages = with pkgs; [
alejandra
nil
];
};
node = {
name = "generic node";
packages = with pkgs; [
nodejs
yarn
nodePackages.vls
nodePackages.typescript-language-server
nodePackages.yaml-language-server
nodePackages.vscode-json-languageserver-bin
nodePackages.vscode-html-languageserver-bin
nodePackages.vscode-css-languageserver-bin
];
};
nodeIonic = {
name = "generic node + ionic";
packages =
shells.node.packages
++ (with pkgs; [
android-studio
]);
};
php = {
name = "generic php";
packages = with pkgs; [
php
phpPackages.composer
];
};
nodePhp = {
name = "generic node + php";
packages = with shells; node.packages ++ php.packages;
};
python = {
name = "generic python";
packages = with pkgs; [
python3Packages.python-lsp-server
];
};
markdown = {
name = "generic markdown";
packages = [mdpls];
};
"beste-schule" = {
name = "beste.schule";
packages =
[
scripts.beste-schule-set-missing-grades
]
++ shells.nodePhp.packages;
};
};
in {
treefmt.projectRootFile = "flake.nix";
treefmt.programs = {
alejandra.enable = true;
};
treefmt.flakeFormatter = true;
pre-commit.check.enable = true;
pre-commit.settings.hooks.markdownlint.enable = true;
pre-commit.settings.hooks.nil.enable = true;
pre-commit.settings.hooks.format = {
enable = true;
entry = "${self'.formatter}/bin/treefmt";
pass_filenames = false;
};
devShells =
(pkgs.lib.attrsets.mapAttrs (name: value:
pkgs.mkShell (pkgs.lib.recursiveUpdate value {
packages = value.packages ++ packagesSharedByAll;
shellHook = ''
echo -e 1>&2 "\n\n Welcome to the development shell!\n\n"
${pkgs.onefetch}/bin/onefetch
'';
}))
shells)
// {
default = self'.devShells.nix.overrideAttrs (final: previous: {
name = "dev";
shellHook = ''
echo -e 1>&2 "\n\n Welcome to the development shell!\n\n"
${config.pre-commit.installationScript}
${pkgs.onefetch}/bin/onefetch
'';
});
};
packages = {
inherit mdpls;
};
};
flake = {
hydraJobs =
builtins.mapAttrs (name: value: {
x86_64-linux = value;
})
self.devShells.x86_64-linux;
templates = {
rust = {
path = ./rust;
description = "Simple Rust + Nix template";
};
};
};
};
}