Skip to content
Open
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
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.

169 changes: 169 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
# 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);

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

pnpmDeps = pkgs.fetchPnpmDeps {
pnpm = pkgs.pnpm_10;
pname = "sable";
inherit (finalAttrs) version src pnpmInstallFlags;
fetcherVersion = 3;
hash = "sha256-9QIBOF1d7Z086IsOAHpOayKA3uNY0e5imYQixHKFXxw=";
};

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

nativeBuildInputs = [
pkgs.nodejs_24
pkgs.pnpm_10
(pkgs.pnpmConfigHook.override { pnpm = pkgs.pnpm_10; })
];

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 ./.;

pnpmDeps = pkgs.fetchPnpmDeps {
pnpm = pkgs.pnpm_10;
pname = "sable";
inherit (finalAttrs) version src pnpmInstallFlags;
fetcherVersion = 3;
hash = "sha256-9QIBOF1d7Z086IsOAHpOayKA3uNY0e5imYQixHKFXxw=";
};

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

nativeBuildInputs = [
pkgs.nodejs_24
pkgs.pnpm_10
(pkgs.pnpmConfigHook.override { pnpm = pkgs.pnpm_10; })
];

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 = with pkgs; [
nodejs_24
corepack
pnpm_10
vitejs
oxlint
oxfmt
knope
typescript
typescript-language-server
nil
nixd
];
shellHook = config.pre-commit.installationScript;
};
};
};
}
6 changes: 3 additions & 3 deletions oxfmt.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { defineConfig } from 'oxfmt';
import type { OxfmtConfig } from 'oxfmt';

export default defineConfig({
export default {
printWidth: 100,
tabWidth: 2,
singleQuote: true,
Expand All @@ -15,4 +15,4 @@ export default defineConfig({
'CHANGELOG.md',
'./changeset',
],
});
} satisfies OxfmtConfig;
Loading