added yarnNix to prevent idf when called on hydraJobs

This commit is contained in:
Sebastian Wendel 2024-05-17 15:04:22 +02:00
parent daa9eb9791
commit 549eb6a202
9 changed files with 6721 additions and 443 deletions

View file

@ -3,12 +3,11 @@
let let
lock = builtins.fromJSON (builtins.readFile ./flake.lock); lock = builtins.fromJSON (builtins.readFile ./flake.lock);
in in
fetchTarball { fetchTarball {
url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz"; url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz";
sha256 = lock.nodes.flake-compat.locked.narHash; sha256 = lock.nodes.flake-compat.locked.narHash;
} }
) )
{ {
src = ./.; src = ./.;
}) }).defaultNix
.defaultNix

View file

@ -1,116 +1,5 @@
{ {
"nodes": { "nodes": {
"alejandra": {
"inputs": {
"fenix": "fenix",
"flakeCompat": "flakeCompat",
"nixpkgs": [
"d2n",
"nixpkgs"
]
},
"locked": {
"lastModified": 1658427149,
"narHash": "sha256-ToD/1z/q5VHsLMrS2h96vjJoLho59eNRtknOUd19ey8=",
"owner": "kamadorueda",
"repo": "alejandra",
"rev": "f5a22afd2adfb249b4e68e0b33aa1f0fb73fb1be",
"type": "github"
},
"original": {
"owner": "kamadorueda",
"repo": "alejandra",
"type": "github"
}
},
"crane": {
"flake": false,
"locked": {
"lastModified": 1670900067,
"narHash": "sha256-VXVa+KBfukhmWizaiGiHRVX/fuk66P8dgSFfkVN4/MY=",
"owner": "ipetkov",
"repo": "crane",
"rev": "59b31b41a589c0a65e4a1f86b0e5eac68081468b",
"type": "github"
},
"original": {
"owner": "ipetkov",
"repo": "crane",
"type": "github"
}
},
"d2n": {
"inputs": {
"alejandra": "alejandra",
"all-cabal-json": [
"nixpkgs"
],
"crane": "crane",
"devshell": "devshell",
"flake-parts": "flake-parts",
"flake-utils-pre-commit": "flake-utils-pre-commit",
"ghc-utils": "ghc-utils",
"gomod2nix": "gomod2nix",
"mach-nix": "mach-nix",
"nix-pypi-fetcher": "nix-pypi-fetcher",
"nixpkgs": "nixpkgs",
"poetry2nix": "poetry2nix",
"pre-commit-hooks": "pre-commit-hooks",
"pruned-racket-catalog": "pruned-racket-catalog"
},
"locked": {
"lastModified": 1676992344,
"narHash": "sha256-TEn5kEi/jL9Dt6O+ZZ7kQwnlAgEv0r4VgQZnav/cfV4=",
"owner": "nix-community",
"repo": "dream2nix",
"rev": "db72710500a80bdf4589b6807d2491a4a0dae3ad",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "dream2nix",
"type": "github"
}
},
"devshell": {
"flake": false,
"locked": {
"lastModified": 1663445644,
"narHash": "sha256-+xVlcK60x7VY1vRJbNUEAHi17ZuoQxAIH4S4iUFUGBA=",
"owner": "numtide",
"repo": "devshell",
"rev": "e3dc3e21594fe07bdb24bdf1c8657acaa4cb8f66",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "devshell",
"type": "github"
}
},
"fenix": {
"inputs": {
"nixpkgs": [
"d2n",
"alejandra",
"nixpkgs"
],
"rust-analyzer-src": "rust-analyzer-src"
},
"locked": {
"lastModified": 1657607339,
"narHash": "sha256-HaqoAwlbVVZH2n4P3jN2FFPMpVuhxDy1poNOR7kzODc=",
"owner": "nix-community",
"repo": "fenix",
"rev": "b814c83d9e6aa5a28d0cf356ecfdafb2505ad37d",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "fenix",
"type": "github"
}
},
"flake-compat": { "flake-compat": {
"flake": false, "flake": false,
"locked": { "locked": {
@ -130,28 +19,9 @@
"flake-parts": { "flake-parts": {
"inputs": { "inputs": {
"nixpkgs-lib": [ "nixpkgs-lib": [
"d2n",
"nixpkgs" "nixpkgs"
] ]
}, },
"locked": {
"lastModified": 1675933616,
"narHash": "sha256-/rczJkJHtx16IFxMmAWu5nNYcSXNg1YYXTHoGjLrLUA=",
"owner": "hercules-ci",
"repo": "flake-parts",
"rev": "47478a4a003e745402acf63be7f9a092d51b83d7",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "flake-parts",
"type": "github"
}
},
"flake-parts_2": {
"inputs": {
"nixpkgs-lib": "nixpkgs-lib"
},
"locked": { "locked": {
"lastModified": 1679737941, "lastModified": 1679737941,
"narHash": "sha256-srSD9CwsVPnUMsIZ7Kt/UegkKUEBcTyU1Rev7mO45S0=", "narHash": "sha256-srSD9CwsVPnUMsIZ7Kt/UegkKUEBcTyU1Rev7mO45S0=",
@ -181,53 +51,6 @@
"type": "github" "type": "github"
} }
}, },
"flake-utils-pre-commit": {
"locked": {
"lastModified": 1644229661,
"narHash": "sha256-1YdnJAsNy69bpcjuoKdOYQX0YxZBiCYZo4Twxerqv7k=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "3cecb5b042f7f209c56ffd8371b2711a290ec797",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"flakeCompat": {
"flake": false,
"locked": {
"lastModified": 1650374568,
"narHash": "sha256-Z+s0J8/r907g149rllvwhb4pKi8Wam5ij0st8PwAh+E=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "b4a34015c698c7793d592d66adbab377907a2be8",
"type": "github"
},
"original": {
"owner": "edolstra",
"repo": "flake-compat",
"type": "github"
}
},
"ghc-utils": {
"flake": false,
"locked": {
"lastModified": 1662774800,
"narHash": "sha256-1Rd2eohGUw/s1tfvkepeYpg8kCEXiIot0RijapUjAkE=",
"ref": "refs/heads/master",
"rev": "bb3a2d3dc52ff0253fb9c2812bd7aa2da03e0fea",
"revCount": 1072,
"type": "git",
"url": "https://gitlab.haskell.org/bgamari/ghc-utils"
},
"original": {
"type": "git",
"url": "https://gitlab.haskell.org/bgamari/ghc-utils"
}
},
"gitignore": { "gitignore": {
"inputs": { "inputs": {
"nixpkgs": [ "nixpkgs": [
@ -249,37 +72,6 @@
"type": "github" "type": "github"
} }
}, },
"gomod2nix": {
"flake": false,
"locked": {
"lastModified": 1627572165,
"narHash": "sha256-MFpwnkvQpauj799b4QTBJQFEddbD02+Ln5k92QyHOSk=",
"owner": "tweag",
"repo": "gomod2nix",
"rev": "67f22dd738d092c6ba88e420350ada0ed4992ae8",
"type": "github"
},
"original": {
"owner": "tweag",
"repo": "gomod2nix",
"type": "github"
}
},
"mach-nix": {
"flake": false,
"locked": {
"lastModified": 1634711045,
"narHash": "sha256-m5A2Ty88NChLyFhXucECj6+AuiMZPHXNbw+9Kcs7F6Y=",
"owner": "DavHau",
"repo": "mach-nix",
"rev": "4433f74a97b94b596fa6cd9b9c0402104aceef5d",
"type": "github"
},
"original": {
"id": "mach-nix",
"type": "indirect"
}
},
"nix-filter": { "nix-filter": {
"locked": { "locked": {
"lastModified": 1678109515, "lastModified": 1678109515,
@ -295,49 +87,16 @@
"type": "github" "type": "github"
} }
}, },
"nix-pypi-fetcher": {
"flake": false,
"locked": {
"lastModified": 1669065297,
"narHash": "sha256-UStjXjNIuIm7SzMOWvuYWIHBkPUKQ8Id63BMJjnIDoA=",
"owner": "DavHau",
"repo": "nix-pypi-fetcher",
"rev": "a9885ac6a091576b5195d547ac743d45a2a615ac",
"type": "github"
},
"original": {
"owner": "DavHau",
"repo": "nix-pypi-fetcher",
"type": "github"
}
},
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1665580254, "lastModified": 1715787315,
"narHash": "sha256-hO61XPkp1Hphl4HGNzj1VvDH5URt7LI6LaY/385Eul4=", "narHash": "sha256-cYApT0NXJfqBkKcci7D9Kr4CBYZKOQKDYA23q8XNuWg=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "f634d427b0224a5f531ea5aa10c3960ba6ec5f0f", "rev": "33d1e753c82ffc557b4a585c77de43d4c922ebb5",
"type": "github" "type": "github"
}, },
"original": { "original": {
"id": "nixpkgs",
"ref": "nixos-unstable",
"type": "indirect"
}
},
"nixpkgs-lib": {
"locked": {
"dir": "lib",
"lastModified": 1675183161,
"narHash": "sha256-Zq8sNgAxDckpn7tJo7V1afRSk2eoVbu3OjI1QklGLNg=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "e1e1b192c1a5aab2960bf0a0bd53a2e8124fa18e",
"type": "github"
},
"original": {
"dir": "lib",
"owner": "NixOS", "owner": "NixOS",
"ref": "nixos-unstable", "ref": "nixos-unstable",
"repo": "nixpkgs", "repo": "nixpkgs",
@ -360,61 +119,14 @@
"type": "github" "type": "github"
} }
}, },
"nixpkgs_2": {
"locked": {
"lastModified": 1677050843,
"narHash": "sha256-3fcFxn58eCtrXrVPeW/nAg6NR5wUERVEf8zOtjPDzuM=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "9e0eed654c705c7cafe192a8eba1610217f70544",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_3": {
"locked": {
"lastModified": 1671271357,
"narHash": "sha256-xRJdLbWK4v2SewmSStYrcLa0YGJpleufl44A19XSW8k=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "40f79f003b6377bd2f4ed4027dde1f8f922995dd",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"poetry2nix": {
"flake": false,
"locked": {
"lastModified": 1666918719,
"narHash": "sha256-BkK42fjAku+2WgCOv2/1NrPa754eQPV7gPBmoKQBWlc=",
"owner": "nix-community",
"repo": "poetry2nix",
"rev": "289efb187123656a116b915206e66852f038720e",
"type": "github"
},
"original": {
"owner": "nix-community",
"ref": "1.36.0",
"repo": "poetry2nix",
"type": "github"
}
},
"pre-commit": { "pre-commit": {
"inputs": { "inputs": {
"flake-compat": "flake-compat", "flake-compat": "flake-compat",
"flake-utils": "flake-utils", "flake-utils": "flake-utils",
"gitignore": "gitignore", "gitignore": "gitignore",
"nixpkgs": "nixpkgs_3", "nixpkgs": [
"nixpkgs"
],
"nixpkgs-stable": "nixpkgs-stable" "nixpkgs-stable": "nixpkgs-stable"
}, },
"locked": { "locked": {
@ -431,71 +143,32 @@
"type": "github" "type": "github"
} }
}, },
"pre-commit-hooks": { "root": {
"inputs": {
"flake-parts": "flake-parts",
"nix-filter": "nix-filter",
"nixpkgs": "nixpkgs",
"pre-commit": "pre-commit",
"treefmt-nix": "treefmt-nix"
}
},
"treefmt-nix": {
"inputs": { "inputs": {
"flake-utils": [
"d2n",
"flake-utils-pre-commit"
],
"nixpkgs": [ "nixpkgs": [
"d2n",
"nixpkgs" "nixpkgs"
] ]
}, },
"locked": { "locked": {
"lastModified": 1646153636, "lastModified": 1715940852,
"narHash": "sha256-AlWHMzK+xJ1mG267FdT8dCq/HvLCA6jwmx2ZUy5O8tY=", "narHash": "sha256-wJqHMg/K6X3JGAE9YLM0LsuKrKb4XiBeVaoeMNlReZg=",
"owner": "cachix", "owner": "numtide",
"repo": "pre-commit-hooks.nix", "repo": "treefmt-nix",
"rev": "b6bc0b21e1617e2b07d8205e7fae7224036dfa4b", "rev": "2fba33a182602b9d49f0b2440513e5ee091d838b",
"type": "github" "type": "github"
}, },
"original": { "original": {
"owner": "cachix", "owner": "numtide",
"repo": "pre-commit-hooks.nix", "repo": "treefmt-nix",
"type": "github"
}
},
"pruned-racket-catalog": {
"flake": false,
"locked": {
"lastModified": 1672537287,
"narHash": "sha256-SuOvXVcLfakw18oJB/PuRMyvGyGG1+CQD3R+TGHIv44=",
"owner": "nix-community",
"repo": "pruned-racket-catalog",
"rev": "c8b89557fb53b36efa2ee48a769c7364df0f6262",
"type": "github"
},
"original": {
"owner": "nix-community",
"ref": "catalog",
"repo": "pruned-racket-catalog",
"type": "github"
}
},
"root": {
"inputs": {
"d2n": "d2n",
"flake-parts": "flake-parts_2",
"nix-filter": "nix-filter",
"nixpkgs": "nixpkgs_2",
"pre-commit": "pre-commit"
}
},
"rust-analyzer-src": {
"flake": false,
"locked": {
"lastModified": 1657557289,
"narHash": "sha256-PRW+nUwuqNTRAEa83SfX+7g+g8nQ+2MMbasQ9nt6+UM=",
"owner": "rust-lang",
"repo": "rust-analyzer",
"rev": "caf23f29144b371035b864a1017dbc32573ad56d",
"type": "github"
},
"original": {
"owner": "rust-lang",
"ref": "nightly",
"repo": "rust-analyzer",
"type": "github" "type": "github"
} }
} }

View file

@ -1,51 +1,72 @@
{ {
description = "nobbz.dev - Website"; description = "nix-hamburg.de - Website";
inputs = { inputs = {
nixpkgs.url = "github:nixos/nixpkgs?ref=nixpkgs-unstable"; nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
d2n.url = "github:nix-community/dream2nix"; flake-parts = {
d2n.inputs.all-cabal-json.follows = "nixpkgs"; url = "github:hercules-ci/flake-parts";
inputs.nixpkgs-lib.follows = "nixpkgs";
};
treefmt-nix = {
url = "github:numtide/treefmt-nix";
inputs.nixpkgs.follows = "nixpkgs";
};
nix-filter.url = "github:numtide/nix-filter"; nix-filter.url = "github:numtide/nix-filter";
flake-parts.url = "github:hercules-ci/flake-parts"; pre-commit = {
pre-commit.url = "github:cachix/pre-commit-hooks.nix"; url = "github:cachix/pre-commit-hooks.nix";
inputs.nixpkgs.follows = "nixpkgs";
};
}; };
outputs = { outputs =
d2n, { self
nix-filter, , flake-parts
flake-parts, , treefmt-nix
pre-commit, , pre-commit
... , ...
} @ inputs: let }@inputs:
systems = ["x86_64-linux" "aarch64-linux"]; let
in systems = [
flake-parts.lib.mkFlake {inherit inputs;} { "x86_64-linux"
"aarch64-linux"
];
in
flake-parts.lib.mkFlake { inherit inputs; } {
inherit systems; inherit systems;
imports = [d2n.flakeModuleBeta pre-commit.flakeModule ./nix/site.nix ./nix/hooks.nix]; imports = [
pre-commit.flakeModule
treefmt-nix.flakeModule
./nix/devshell.nix
./nix/pre-commit.nix
./nix/package.nix
];
dream2nix.config.projectRoot = ./.; perSystem =
{ config
perSystem = { , pkgs
self', , self'
config, , ...
pkgs, }:
system, {
... apps = {
}: { serve.program = "${pkgs.writeShellScript "serve" ''
apps.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.default = self'.packages.nix-hh-website;
devShells.default = pkgs.mkShell {
packages = builtins.attrValues {
inherit (pkgs) yarn;
inherit (pkgs) alejandra nil;
}; };
# shellHook = config.pre-commit.installationScript;
packages.default = self'.packages.nix-hamburg;
treefmt.config = {
projectRootFile = "flake.nix";
programs.nixpkgs-fmt.enable = true;
};
formatter = config.treefmt.build.wrapper;
}; };
flake.hydraJobs = {
inherit (self) checks packages;
}; };
}; };
} }

51
nix/devshell.nix Normal file
View file

@ -0,0 +1,51 @@
{
perSystem =
{ pkgs, config, ... }:
{
devShells.default = pkgs.mkShell {
inputsFrom = [ config.treefmt.build.devShell ];
nativeBuildInputs = with pkgs; [
# ide
(vscode-with-extensions.override {
vscode = vscodium;
vscodeExtensions = with vscode-extensions; [
arrterian.nix-env-selector
astro-build.astro-vscode
bradlc.vscode-tailwindcss
bbenoist.nix
jnoortheen.nix-ide
mkhl.direnv
ritwickdey.liveserver
];
})
# formater
nixpkgs-fmt
nodePackages_latest.prettier
# lsp
nil
nodePackages_latest.typescript-language-server
nodePackages_latest.vscode-css-languageserver-bin
nodePackages_latest.vscode-html-languageserver-bin
tailwindcss-language-server
# nix
deadnix
statix
# node
nodePackages_latest.nodejs
nodePackages_latest.typescript
nodePackages_latest.yarn
yarn2nix
# html
html5validator
];
shellHook = config.pre-commit.installationScript;
};
};
}

View file

@ -1,13 +0,0 @@
{self, ...}: {
perSystem = {pkgs, ...}: {
pre-commit.check.enable = true;
pre-commit.settings.hooks.nixpkgs-fmt.enable = false;
pre-commit.settings.hooks.alejandra.enable = true;
pre-commit.settings.hooks.prettier.enable = true;
pre-commit.settings.hooks.eslint.enable = true;
pre-commit.settings.hooks.eslint.pass_filenames = false;
pre-commit.settings.settings.eslint.binPath = "${pkgs.nodePackages.eslint}/bin/eslint src";
pre-commit.settings.settings.eslint.extensions = "\\.(js|ts|jsx|tsx|astro|md|mdx|cjs|ts)$";
};
}

54
nix/package.nix Normal file
View file

@ -0,0 +1,54 @@
{ inputs, ... }:
let
inherit (inputs.nix-filter.lib) filter inDirectory matchExt;
in
{
perSystem =
{ pkgs, ... }:
{
packages.nix-hamburg = pkgs.mkYarnPackage rec {
name = "nix-hamburg";
src = filter {
root = ../.;
include = [
(inDirectory "public")
(inDirectory "src")
(matchExt "js")
(matchExt "cjs")
(matchExt "mjs")
(matchExt "json")
(matchExt "ts")
../package.json
../yarn.lock
../nix/yarn.nix
];
};
packageJSON = ../package.json;
yarnLock = ../yarn.lock;
yarnNix = ../nix/yarn.nix;
yarnFlags = [
"--offline"
"--production=true"
];
CI = "true";
pkgConfig.sharp = {
nativeBuildInputs = builtins.attrValues {
inherit (pkgs.nodePackages) node-gyp;
inherit (pkgs) python3 pkg-config;
};
buildInputs = with pkgs; [ vips.dev ];
postInstall = "node-gyp --node-dir=${pkgs.nodePackages.nodejs} rebuild";
};
postConfigure = "export HOME=$(mktemp -d)";
buildPhase = "yarn build";
installPhase = "mv -v deps/${name}/dist \${out}";
distPhase = "true";
};
};
}

13
nix/pre-commit.nix Normal file
View file

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

View file

@ -1,37 +0,0 @@
{inputs, ...}: let
inherit (inputs.nix-filter.lib) filter inDirectory matchExt;
in {
perSystem = {config, ...}: {
dream2nix.inputs.self = {
source = filter {
root = ./..;
include = [
(inDirectory "src")
(inDirectory "public")
(matchExt "js")
(matchExt "cjs")
(matchExt "mjs")
../package.json
../yarn.lock
];
};
projects.nix-hh-website = {
name = "nix-hh-website";
subsystem = "nodejs";
translator = "yarn-lock";
subsystemInfo.nodejs = 18;
};
packageOverrides.nix-hh-website.copy-nix-hh-website = {
installPhase = ''
mkdir -p $out
cp -rv ./dist/* $out
'';
};
};
packages.nix-hh-website = config.dream2nix.outputs.self.packages.nix-hh-website;
};
}

6517
nix/yarn.nix Normal file

File diff suppressed because it is too large Load diff