mirror of
https://github.com/sbrow/thor.git
synced 2026-08-26 19:33:32 -04:00
165 lines
4.4 KiB
Nix
165 lines
4.4 KiB
Nix
{
|
|
description = "A dev environment";
|
|
|
|
inputs = {
|
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-26.05";
|
|
nixpkgs-unstable.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
|
|
|
flake-parts.url = "github:hercules-ci/flake-parts";
|
|
# process-compose-flake.url = "github:Platonic-Systems/process-compose-flake";
|
|
treefmt-nix.url = "github:numtide/treefmt-nix";
|
|
treefmt-nix.inputs.nixpkgs.follows = "nixpkgs";
|
|
};
|
|
|
|
outputs =
|
|
inputs@{
|
|
self,
|
|
flake-parts,
|
|
nixpkgs,
|
|
nixpkgs-unstable,
|
|
# , process-compose-flake
|
|
treefmt-nix,
|
|
}:
|
|
flake-parts.lib.mkFlake { inherit inputs; } {
|
|
imports = [
|
|
inputs.treefmt-nix.flakeModule
|
|
# inputs.process-compose-flake.flakeModule
|
|
];
|
|
systems = [ "x86_64-linux" ];
|
|
|
|
perSystem =
|
|
{
|
|
pkgs,
|
|
system,
|
|
inputs',
|
|
...
|
|
}:
|
|
let
|
|
mkGrammarStaticLib = name: src: pkgs.stdenv.mkDerivation {
|
|
inherit name src;
|
|
dontConfigure = true;
|
|
|
|
buildPhase = ''
|
|
runHook preBuild
|
|
if [ -f src/scanner.cc ]; then
|
|
$CXX -fPIC -c src/scanner.cc -o scanner.o
|
|
elif [ -f src/scanner.c ]; then
|
|
$CC -fPIC -c src/scanner.c -o scanner.o
|
|
fi
|
|
$CC -fPIC -c src/parser.c -o parser.o
|
|
runHook postBuild
|
|
'';
|
|
|
|
installPhase = ''
|
|
runHook preInstall
|
|
mkdir -p $out/lib
|
|
ar rcs $out/lib/lib${name}.a *.o
|
|
runHook postInstall
|
|
'';
|
|
};
|
|
|
|
html-grammar = mkGrammarStaticLib "tree-sitter-html"
|
|
pkgs.tree-sitter-grammars.tree-sitter-html.src;
|
|
css-grammar = mkGrammarStaticLib "tree-sitter-css"
|
|
pkgs.tree-sitter-grammars.tree-sitter-css.src;
|
|
in
|
|
{
|
|
_module.args.pkgs = import nixpkgs {
|
|
inherit system;
|
|
config.allowUnfree = true;
|
|
|
|
overlays = [
|
|
(final: prev: { unstable = inputs'.nixpkgs-unstable.legacyPackages; })
|
|
];
|
|
};
|
|
|
|
treefmt = {
|
|
# Used to find the project root
|
|
projectRootFile = "flake.nix";
|
|
settings.global.excludes = [
|
|
".direnv/**"
|
|
".jj/**"
|
|
".env"
|
|
".envrc"
|
|
".env.local"
|
|
];
|
|
|
|
# Format nix files
|
|
programs.nixpkgs-fmt.enable = true;
|
|
programs.deadnix.enable = true;
|
|
|
|
# Format js, json, and yaml files
|
|
programs.prettier.enable = true;
|
|
settings.formatter.prettier = {
|
|
excludes = [
|
|
"public/**"
|
|
"resources/js/modernizr.js"
|
|
"storage/app/caniuse.json"
|
|
"*.md"
|
|
];
|
|
};
|
|
};
|
|
|
|
#process-compose.default.settings.processes = { };
|
|
|
|
packages.default = pkgs.stdenv.mkDerivation rec {
|
|
pname = "thor";
|
|
version = nixpkgs.lib.trim (builtins.readFile ./version.txt);
|
|
src = ./.;
|
|
|
|
nativeBuildInputs = [
|
|
pkgs.odin
|
|
pkgs.pkg-config
|
|
];
|
|
|
|
buildInputs = [
|
|
pkgs.git
|
|
pkgs.cmark
|
|
pkgs.tree-sitter
|
|
html-grammar
|
|
css-grammar
|
|
];
|
|
|
|
LIBRARY_PATH = "${html-grammar}/lib:${css-grammar}/lib";
|
|
|
|
doCheck = true;
|
|
checkPhase = ''
|
|
runHook preCheck
|
|
odin test . -all-packages
|
|
runHook postCheck
|
|
'';
|
|
|
|
buildPhase = ''
|
|
runHook preBuild
|
|
odin build . -o:speed -out:${pname}-keep
|
|
runHook postBuild
|
|
'';
|
|
|
|
installPhase = ''
|
|
runHook preInstall
|
|
install -Dm755 ${pname}-keep $out/bin/${pname}
|
|
runHook postInstall
|
|
'';
|
|
};
|
|
|
|
devShells.default = pkgs.mkShell {
|
|
buildInputs = with pkgs; [
|
|
odin
|
|
ols
|
|
cmark
|
|
tree-sitter
|
|
|
|
# IDE
|
|
unstable.helix
|
|
typescript-language-server
|
|
vscode-langservers-extracted
|
|
];
|
|
|
|
shellHook = ''
|
|
export LIBRARY_PATH="${html-grammar}/lib:${css-grammar}/lib:$LIBRARY_PATH"
|
|
'';
|
|
};
|
|
};
|
|
};
|
|
}
|