Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions .github/workflows/flake-lock-fix.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Fix flake hashes

on:
push:
branches: [dev]
paths: ['pnpm-lock.yaml']

jobs:
fix:
name: Fix flake hashes
runs-on: ubuntu-latest
permissions:
id-token: write
contents: write
steps:
- name: Checkout dev
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
ref: dev
persist-credentials: true

- name: Install Determinate Nix
uses: DeterminateSystems/determinate-nix-action@bafaa638b9d5ec0e7e3ac1a7fc80453ef1fd265f # v3.20.0

- id: check
run: nix flake check -L
continue-on-error: true

- name: Fix hash mismatches
if: steps.check.outcome == 'failure'
run: determinate-nixd fix hashes --auto-apply

- name: Commit and push if changed
if: steps.check.outcome == 'failure'
shell: bash
run: |
set -euo pipefail
if git diff --quiet; then
echo "No changes after fix hashes; nothing to commit."
exit 0
fi
git config user.name "sable-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add --update --ignore-removal .
git commit -m "chore(nix): auto-fix nix hashes"
git push origin HEAD:dev --force-with-lease
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,12 @@ build.sh

# the following line was added with nvim by Shea because its annoying to clear every so often
.vscode/bookmarks.json

# Nix things
## nix build output
result
## direnv config + local state
.envrc
.direnv
## auto-generated pre-commit config
.pre-commit-config.yaml
4 changes: 3 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,7 @@
},
"[json]": {
"editor.defaultFormatter": "oxc.oxc-vscode"
}
},
"nixEnvSelector.nixFile": "${workspaceFolder}/flake.nix",
"nixEnvSelector.useFlakes": true
}
142 changes: 142 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

181 changes: 181 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,181 @@
# SPDX-License-Identifier: AGPL-3.0
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-parts.url = "github:hercules-ci/flake-parts";
git-hooks.url = "github:cachix/git-hooks.nix";
git-hooks.inputs.nixpkgs.follows = "nixpkgs";
treefmt-nix.url = "github:numtide/treefmt-nix";
treefmt-nix.inputs.nixpkgs.follows = "nixpkgs";
};

outputs =
inputs@{ flake-parts, ... }:
flake-parts.lib.mkFlake { inherit inputs; } {
imports = [
inputs.git-hooks.flakeModule
inputs.treefmt-nix.flakeModule
];

systems = [
"x86_64-linux"
"aarch64-linux"
"x86_64-darwin"
"aarch64-darwin"
];

perSystem =
{
config,
pkgs,
lib,
...
}:
let
self = inputs.self;

packageJson = builtins.fromJSON (builtins.readFile ./package.json);

nodejs = pkgs.nodejs_24;
pnpm = pkgs.pnpm_10;
pnpmConfigHook = pkgs.pnpmConfigHook.override { inherit pnpm; };

pnpmNativeBuildInputs = [
nodejs
pnpm
pnpmConfigHook
];

mkPnpmDeps =
{
src,
version,
pnpmInstallFlags,
}:
pkgs.fetchPnpmDeps {
inherit
pnpm
src
version
pnpmInstallFlags
;
pname = "sable";
fetcherVersion = 3;
hash = "sha256-9QIBOF1d7Z086IsOAHpOayKA3uNY0e5imYQixHKFXxw=";
};

mkPnpmCheck =
name: script:
pkgs.stdenv.mkDerivation (finalAttrs: {
pname = "sable-${name}";
inherit (packageJson) version;
src = lib.cleanSource ./.;

pnpmInstallFlags = [ "--ignore-scripts" ];

pnpmDeps = mkPnpmDeps {
inherit (finalAttrs) src version pnpmInstallFlags;
};

nativeBuildInputs = pnpmNativeBuildInputs;

buildPhase = ''
runHook preBuild
pnpm run ${script}
runHook postBuild
'';

installPhase = ''
runHook preInstall
touch $out
runHook postInstall
'';

doCheck = false;
});
in
{
treefmt = {
projectRootFile = "flake.nix";
programs = {
nixfmt.enable = true;
oxfmt.enable = true;
};
settings.global.excludes = [
"dist"
"node_modules"
"pnpm-lock.yaml"
"pnpm-workspace.yaml"
"package.json"
"LICENSE"
"CHANGELOG.md"
"./changeset"
];
};
pre-commit.settings.hooks = {
treefmt = {
enable = true;
package = config.treefmt.build.wrapper;
};
};

packages.sable = pkgs.stdenv.mkDerivation (finalAttrs: {
pname = "sable";
inherit (packageJson) version;
src = lib.cleanSource ./.;

# ignoring knope for building
pnpmInstallFlags = [ "--ignore-scripts" ];

pnpmDeps = mkPnpmDeps {
inherit (finalAttrs) src version pnpmInstallFlags;
};

nativeBuildInputs = pnpmNativeBuildInputs;

env.VITE_BUILD_HASH = self.shortRev or self.dirtyShortRev or "";
env.VITE_IS_RELEASE_TAG = "false";

buildPhase = ''
runHook preBuild
pnpm run build
runHook postBuild
'';

installPhase = ''
runHook preInstall
cp -r dist $out
runHook postInstall
'';
});

packages.default = config.packages.sable;

checks = {
build = config.packages.sable;
lint = mkPnpmCheck "lint" "lint";
fmt = mkPnpmCheck "fmt" "fmt:check";
test = mkPnpmCheck "test" "test:run";
typecheck = mkPnpmCheck "typecheck" "typecheck";
knip = mkPnpmCheck "knip" "knip";
};

devShells.default = pkgs.mkShell {
packages = [
nodejs
pnpm
pkgs.corepack
pkgs.vitejs
pkgs.oxlint
pkgs.oxfmt
pkgs.knope
pkgs.typescript
pkgs.typescript-language-server
pkgs.nil
pkgs.nixd
];
shellHook = config.pre-commit.installationScript;
};
};
};
}
Loading
Loading