Update Nix configuration

Also run `nix fmt` on JSON files.
This commit is contained in:
Hoang Nguyen 2024-03-07 00:00:00 +07:00
parent aa4bfbcae8
commit 7b90296060
Signed by: folliehiyuki
GPG key ID: B0567C20730E9B11
5 changed files with 30 additions and 94 deletions

View file

@ -5,11 +5,11 @@
"systems": "systems"
},
"locked": {
"lastModified": 1701680307,
"narHash": "sha256-kAuep2h5ajznlPMD9rnQyffWG8EM/C73lejGofXvdM8=",
"lastModified": 1709126324,
"narHash": "sha256-q6EQdSeUZOG26WelxqkmR7kArjgWCdw5sfJVHPH/7j8=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "4022d587cbbfd70fe950c1e2083a02621806a725",
"rev": "d465f4819400de7c8d874d50b982301f28a84605",
"type": "github"
},
"original": {
@ -20,16 +20,16 @@
},
"nixpkgs": {
"locked": {
"lastModified": 1703438236,
"narHash": "sha256-aqVBq1u09yFhL7bj1/xyUeJjzr92fXVvQSSEx6AdB1M=",
"lastModified": 1709780214,
"narHash": "sha256-p4iDKdveHMhfGAlpxmkCtfQO3WRzmlD11aIcThwPqhk=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "5f64a12a728902226210bf01d25ec6cbb9d9265b",
"rev": "f945939fd679284d736112d3d5410eb867f3b31c",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-unstable",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
@ -63,11 +63,11 @@
]
},
"locked": {
"lastModified": 1702979157,
"narHash": "sha256-RnFBbLbpqtn4AoJGXKevQMCGhra4h6G2MPcuTSZZQ+g=",
"lastModified": 1709546977,
"narHash": "sha256-R0bi8zAWt1s1q7lSvwiFI8+kEL29rm4WtYTqPgjlEBs=",
"owner": "numtide",
"repo": "treefmt-nix",
"rev": "2961375283668d867e64129c22af532de8e77734",
"rev": "e7a277c5d12bf570efa2427d9cfdb760b9a0512f",
"type": "github"
},
"original": {

View file

@ -8,7 +8,7 @@
description = "folliehiyuki's infrastructure configuration";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
flake-utils.url = "github:numtide/flake-utils";
treefmt-nix = {
@ -20,75 +20,29 @@
outputs = { self, nixpkgs, flake-utils, treefmt-nix, ... }:
flake-utils.lib.eachDefaultSystem (system:
let
inherit (nixpkgs) lib;
inherit (flake-utils.lib) mkApp;
pkgs = nixpkgs.legacyPackages."${system}";
treefmtEval = treefmt-nix.lib.evalModule pkgs ./treefmt.nix;
shellHook = ''
export NIX_CONFIG="experimental-features = nix-command flakes"
export GOTOOLCHAIN=local
export PULUMI_SKIP_UPDATE_CHECK=true
export PULUMI_AUTOMATION_API_SKIP_VERSION_CHECK=true
'';
pulumiInputs = with pkgs; [
go
nodejs-slim
nodePackages.pnpm
pulumi
pulumiPackages.pulumi-language-nodejs
];
# `pulumi up` -> nix run .#up:<stack>
# `pulumi preview` -> nix run .#plan:<stack>
targets.pulumi =
let
pulumiStacks = builtins.attrNames (lib.filterAttrs
(key: value: value == "directory")
(builtins.readDir ./stacks));
pulumiCommands = {
plan = "pulumi preview --diff";
up = "pulumi up --show-replacement-steps";
};
in
lib.concatMapAttrs
(name: value: lib.mapAttrs'
(key: val:
lib.nameValuePair (name + ":" + key) val)
value)
(lib.mapAttrs
(key: command: lib.genAttrs
pulumiStacks
(stack: mkApp {
drv = pkgs.writeShellApplication {
name = key + "-" + stack;
runtimeInputs = pulumiInputs;
text = ''
${shellHook}
cd ./stacks/${stack}
pulumi login file:///home/follie/.local/share/pulumi
pulumi stack select ${stack}
${command}
'';
};
})
)
pulumiCommands);
in
{
apps = lib.foldr (a: b: a // b) { } (lib.attrValues targets);
checks = with pkgs; {
treefmt = treefmtEval.config.build.check self;
ansible-lint = writeShellScriptBin "ansible-lint" ''
${ansible-lint}/bin/ansible-lint ./playbooks/
'';
golangci-lint = writeShellApplication {
name = "golangci-lint";
runtimeInputs = [ go ];
text = "${golangci-lint}/bin/golangci-lint run";
};
license = writeShellScriptBin "reuse-lint" ''
${reuse}/bin/reuse lint
'';

32
nx.json
View file

@ -1,20 +1,14 @@
{
"$schema": "./node_modules/nx/schemas/nx-schema.json",
"plugins": [
"@nx-extend/pulumi"
],
"plugins": ["@nx-extend/pulumi"],
"targetDefaults": {
"preview": {
"executor": "@nx-extend/pulumi:preview",
"dependsOn": [
"res:build"
]
"dependsOn": ["res:build"]
},
"up": {
"executor": "@nx-extend/pulumi:up",
"dependsOn": [
"res:build"
]
"dependsOn": ["res:build"]
},
"refresh": {
"executor": "@nx-extend/pulumi:refresh",
@ -25,18 +19,12 @@
"res:build": {
"cache": true,
"executor": "nx:run-commands",
"dependsOn": [
"^res:build"
],
"dependsOn": ["^res:build"],
"options": {
"commands": [
"rescript build"
],
"commands": ["rescript build"],
"cwd": "{projectRoot}"
},
"inputs": [
"{projectRoot}/src/**/*.res"
],
"inputs": ["{projectRoot}/src/**/*.res"],
"outputs": [
"{projectRoot}/src/**/*.res.js",
"{projectRoot}/src/**/*.gen.tsx"
@ -45,18 +33,14 @@
"res:clean": {
"executor": "nx:run-commands",
"options": {
"commands": [
"rescript clean"
],
"commands": ["rescript clean"],
"cwd": "{projectRoot}"
}
},
"res:dev": {
"executor": "nx:run-commands",
"options": {
"commands": [
"rescript -w"
],
"commands": ["rescript -w"],
"cwd": "{projectRoot}"
}
}

View file

@ -8,9 +8,7 @@
"rescript": "^11.0.1"
},
"nx": {
"implicitDependencies": [
"shared"
],
"implicitDependencies": ["shared"],
"targets": {
"preview": {
"options": {