dev/flake.nix

182 lines
5 KiB
Nix
Raw Normal View History

2022-08-26 17:17:50 +02:00
{
2023-11-04 11:44:12 +01:00
description = "All things development";
inputs.flake-parts.url = "github:hercules-ci/flake-parts";
inputs.nixpkgs.url = "github:NixOS/nixpkgs?ref=nixpkgs-unstable";
2023-11-04 20:45:59 +01:00
inputs.pre-commit-hooks-nix.url = "github:cachix/pre-commit-hooks.nix";
inputs.treefmt-nix.url = "github:numtide/treefmt-nix";
2022-08-26 17:17:50 +02:00
2022-10-05 18:17:45 +02:00
nixConfig = {
nix = ["http://cache.home"];
};
2023-11-04 11:44:12 +01:00
outputs = inputs @ {
flake-parts,
2023-11-04 20:45:59 +01:00
pre-commit-hooks-nix,
treefmt-nix,
2022-08-26 17:17:50 +02:00
self,
2023-11-04 11:44:12 +01:00
...
2022-08-26 17:17:50 +02:00
}:
2023-11-04 11:44:12 +01:00
flake-parts.lib.mkFlake {inherit inputs;} {
2023-11-04 20:45:59 +01:00
imports = [
treefmt-nix.flakeModule
pre-commit-hooks-nix.flakeModule
];
2023-11-04 11:44:12 +01:00
systems = ["x86_64-linux"];
perSystem = {
config,
self',
pkgs,
lib,
...
}: let
mdpls = let
version = "30761508593d85b5743ae39c4209947740eec92d";
in
pkgs.rustPlatform.buildRustPackage {
inherit version;
pname = "mdpls";
2022-10-05 18:17:45 +02:00
2023-11-04 11:44:12 +01:00
src = pkgs.fetchFromGitHub {
owner = "euclio";
repo = "mdpls";
rev = version;
sha256 = "sha256-4n1MX8hS7JmKzaL8GfMq2q3IdwE4fvMmWOYo7rY+cdY=";
};
2022-10-10 14:55:46 +02:00
2023-11-04 11:44:12 +01:00
cargoSha256 = "sha256-J49A43BSCJGqaY7AX7XsoMwy6sgyaIx2Vz57Z1cFItc=";
2022-10-10 14:55:46 +02:00
};
2023-11-04 11:44:12 +01:00
packagesSharedByAll = with pkgs; [
diff-so-fancy
pre-commit
2023-11-04 11:44:12 +01:00
];
2023-04-20 09:36:49 +02:00
2023-11-04 11:44:12 +01:00
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;
};
2023-09-20 09:51:25 +02:00
};
2023-11-04 11:44:12 +01:00
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;
};
2022-10-10 14:55:46 +02:00
};
2023-11-04 11:44:12 +01:00
in {
2023-11-04 20:45:59 +01:00
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
'';
2023-11-04 20:45:59 +01:00
}))
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
2023-11-04 20:45:59 +01:00
'';
});
};
2023-11-04 11:44:12 +01:00
packages = {
inherit mdpls;
2023-09-20 09:51:25 +02:00
};
2022-08-26 17:17:50 +02:00
};
2023-11-04 11:44:12 +01:00
flake = {
hydraJobs =
builtins.mapAttrs (name: value: {
x86_64-linux = value;
})
self.devShells.x86_64-linux;
2023-01-03 11:34:31 +01:00
2023-11-04 11:44:12 +01:00
templates = {
rust = {
path = ./rust;
description = "Simple Rust + Nix template";
};
};
2023-01-03 11:34:31 +01:00
};
2023-11-04 11:44:12 +01:00
};
2022-08-26 17:17:50 +02:00
}