added hydra jobs and flakes cleanup

This commit is contained in:
Sebastian Wendel 2024-05-07 17:20:50 +02:00
parent dea33e48f9
commit e94bc36a01
5 changed files with 83 additions and 53 deletions

View file

@ -90,18 +90,17 @@
}, },
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1713805509, "lastModified": 1714906307,
"narHash": "sha256-YgSEan4CcrjivCNO5ZNzhg7/8ViLkZ4CB/GrGBVSudo=", "narHash": "sha256-UlRZtrCnhPFSJlDQE7M0eyhgvuuHBTe1eJ9N9AQlJQ0=",
"owner": "nixos", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "1e1dc66fe68972a76679644a5577828b6a7e8be4", "rev": "25865a40d14b3f9cf19f19b924e2ab4069b09588",
"type": "github" "type": "github"
}, },
"original": { "original": {
"owner": "nixos", "id": "nixpkgs",
"ref": "nixpkgs-unstable", "ref": "nixos-unstable",
"repo": "nixpkgs", "type": "indirect"
"type": "github"
} }
}, },
"nixpkgs-lib": { "nixpkgs-lib": {
@ -154,6 +153,22 @@
"type": "github" "type": "github"
} }
}, },
"nixpkgs_3": {
"locked": {
"lastModified": 1708475490,
"narHash": "sha256-g1v0TsWBQPX97ziznfJdWhgMyMGtoBFs102xSYO4syU=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "0e74ca98a74bc7270d28838369593635a5db3260",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"pre-commit": { "pre-commit": {
"inputs": { "inputs": {
"flake-compat": "flake-compat", "flake-compat": "flake-compat",
@ -181,7 +196,8 @@
"flake-parts": "flake-parts", "flake-parts": "flake-parts",
"nix-filter": "nix-filter", "nix-filter": "nix-filter",
"nixpkgs": "nixpkgs", "nixpkgs": "nixpkgs",
"pre-commit": "pre-commit" "pre-commit": "pre-commit",
"treefmt-nix": "treefmt-nix"
} }
}, },
"systems": { "systems": {
@ -198,6 +214,24 @@
"repo": "default", "repo": "default",
"type": "github" "type": "github"
} }
},
"treefmt-nix": {
"inputs": {
"nixpkgs": "nixpkgs_3"
},
"locked": {
"lastModified": 1714058656,
"narHash": "sha256-Qv4RBm4LKuO4fNOfx9wl40W2rBbv5u5m+whxRYUMiaA=",
"owner": "numtide",
"repo": "treefmt-nix",
"rev": "c6aaf729f34a36c445618580a9f95a48f5e4e03f",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "treefmt-nix",
"type": "github"
}
} }
}, },
"root": "root", "root": "root",

View file

@ -2,48 +2,43 @@
description = "srx.digital - Website"; description = "srx.digital - Website";
inputs = { inputs = {
nixpkgs.url = "github:nixos/nixpkgs?ref=nixpkgs-unstable"; nixpkgs.url = "nixpkgs/nixos-unstable";
flake-parts.url = "github:hercules-ci/flake-parts"; flake-parts.url = "github:hercules-ci/flake-parts";
treefmt-nix.url = "github:numtide/treefmt-nix";
nix-filter.url = "github:numtide/nix-filter"; nix-filter.url = "github:numtide/nix-filter";
pre-commit.url = "github:cachix/pre-commit-hooks.nix"; pre-commit.url = "github:cachix/pre-commit-hooks.nix";
}; };
outputs = { outputs = { self, flake-parts, treefmt-nix, pre-commit, ... }@inputs:
flake-parts, let systems = [ "x86_64-linux" "aarch64-linux" ];
nix-filter, in flake-parts.lib.mkFlake { inherit inputs; } {
pre-commit,
...
} @ inputs: let
systems = ["x86_64-linux" "aarch64-linux"];
in
flake-parts.lib.mkFlake {inherit inputs;} {
inherit systems; inherit systems;
imports = [ imports = [
pre-commit.flakeModule pre-commit.flakeModule
treefmt-nix.flakeModule
./nix/hooks.nix ./nix/hooks.nix
./nix/devshell.nix ./nix/devshell.nix
./nix/package.nix ./nix/package.nix
]; ];
perSystem = { config, pkgs, self', ... }: {
perSystem = {
config,
pkgs,
self',
inputs',
system,
...
}: {
apps = { apps = {
serve.program = "${pkgs.writeShellScript "serve" '' serve.program = "${pkgs.writeShellScript "serve" ''
${pkgs.miniserve}/bin/miniserve -p 3001 --index index.html ${self'.packages.default} ${pkgs.miniserve}/bin/miniserve -p 3001 --index index.html ${self'.packages.default}
''}"; ''}";
}; };
packages = { packages.default = self'.packages.srx-digital;
default = self'.packages.srx-digital;
treefmt.config = {
projectRootFile = "flake.nix";
programs.nixpkgs-fmt.enable = true;
}; };
formatter = config.treefmt.build.wrapper;
}; };
flake.hydraJobs = { inherit (self) packages; };
}; };
} }

View file

@ -1,6 +1,8 @@
{ {
perSystem = { pkgs, config, ... }: { perSystem = { pkgs, config, ... }: {
devShells.default = pkgs.mkShell { devShells.default = pkgs.mkShell {
inputsFrom = [ config.treefmt.build.devShell ];
nativeBuildInputs = with pkgs; [ nativeBuildInputs = with pkgs; [
# ide # ide
(vscode-with-extensions.override { (vscode-with-extensions.override {
@ -17,7 +19,7 @@
}) })
# formater # formater
nixfmt nixpkgs-fmt
nodePackages_latest.prettier nodePackages_latest.prettier
# lsp # lsp
@ -27,6 +29,10 @@
nodePackages_latest.vscode-html-languageserver-bin nodePackages_latest.vscode-html-languageserver-bin
tailwindcss-language-server tailwindcss-language-server
# nix
deadnix
statix
# node # node
nodePackages_latest.nodejs nodePackages_latest.nodejs
nodePackages_latest.typescript nodePackages_latest.typescript
@ -36,7 +42,9 @@
# html # html
html5validator html5validator
]; ];
shellHook = config.pre-commit.installationScript; shellHook = ''
${config.pre-commit.installationScript}
'';
}; };
}; };
} }

View file

@ -1,10 +1,13 @@
{ {
perSystem = {pkgs, ...}: { perSystem.pre-commit = {
pre-commit = { check.enable = true;
check.enable = true; settings.hooks = {
settings = { markdownlint.enable = true;
hooks = {}; shellcheck.enable = true;
}; nixpkgs-fmt.enable = true;
deadnix.enable = true;
statix.enable = true;
eslint.enable = true;
}; };
}; };
} }

View file

@ -1,12 +1,7 @@
{inputs, ...}: let { inputs, ... }:
inherit (inputs.nix-filter.lib) filter inDirectory matchExt; let inherit (inputs.nix-filter.lib) filter inDirectory matchExt;
in { in {
perSystem = { perSystem = { pkgs, ... }: {
config,
pkgs,
inputs',
...
}: {
packages.srx-digital = pkgs.mkYarnPackage rec { packages.srx-digital = pkgs.mkYarnPackage rec {
name = "srx-digital"; name = "srx-digital";
@ -30,10 +25,7 @@ in {
packageJSON = ../package.json; packageJSON = ../package.json;
yarnLock = ../yarn.lock; yarnLock = ../yarn.lock;
yarnFlags = [ yarnFlags = [ "--offline" "--production=true" ];
"--offline"
"--production=true"
];
pkgConfig.sharp = { pkgConfig.sharp = {
nativeBuildInputs = with pkgs; [ nativeBuildInputs = with pkgs; [
@ -42,9 +34,7 @@ in {
nodePackages.node-gyp nodePackages.node-gyp
]; ];
buildInputs = with pkgs; [ buildInputs = with pkgs; [ vips.dev ];
vips.dev
];
postInstall = '' postInstall = ''
${pkgs.nodePackages.node-gyp}/bin/node-gyp --node-dir=${pkgs.nodePackages.nodejs}/include/node rebuild ${pkgs.nodePackages.node-gyp}/bin/node-gyp --node-dir=${pkgs.nodePackages.nodejs}/include/node rebuild