Working with nix

This commit is contained in:
Henry Hiles 2025-08-10 16:21:07 -04:00
commit 442b0f567d
No known key found for this signature in database
4 changed files with 26 additions and 53 deletions

4
.gitignore vendored
View file

@ -1,3 +1 @@
dist/ .direnv/
.direnv/
node_modules/

View file

@ -1,27 +0,0 @@
NAME=auto-rotate
DOMAIN=henryhiles.com
.PHONY: all pack install clean
all: dist/extension.js
node_modules: package.json
npm install
dist/extension.js: node_modules
tsc
$(NAME).zip: dist/extension.js
@cp metadata.json dist/
@(cd dist && zip ../$(NAME).zip -9r .)
pack: $(NAME).zip
install: $(NAME).zip
@touch ~/.local/share/gnome-shell/extensions/$(NAME)@$(DOMAIN)
@rm -rf ~/.local/share/gnome-shell/extensions/$(NAME)@$(DOMAIN)
@mv dist ~/.local/share/gnome-shell/extensions/$(NAME)@$(DOMAIN)
clean:
@rm -rf dist node_modules $(NAME).zip

View file

@ -9,27 +9,33 @@
systems = ["x86_64-linux" "aarch64-linux"]; systems = ["x86_64-linux" "aarch64-linux"];
perSystem = { perSystem = {
lib, lib,
self',
pkgs, pkgs,
system, system,
... ...
}: { }: let
name = "auto-rotate";
uuid = "${name}@henryhiles.com";
extDir = "share/gnome-shell/extensions/${uuid}";
in {
_module.args.pkgs = import inputs.nixpkgs {inherit system;}; _module.args.pkgs = import inputs.nixpkgs {inherit system;};
packages.default = pkgs.stdenv.mkDerivation { packages.default = pkgs.buildNpmPackage (finalAttrs: {
pname = "auto-rotate"; pname = name;
version = "1.0.0"; version = "1.0.0";
src = ./.; src = ./.;
nativeBuildInputs = with pkgs; [nodejs glib.dev typescript zip]; nativeBuildInputs = with pkgs; [typescript];
npmDepsHash = "sha256-YlKPinb6wmpo6kL/lL7DQnhVmnR9zJaIOKGzBg9kvRM=";
buildPhase = '' buildPhase = ''
npm install
tsc tsc
cp metadata.json dist/
''; '';
installPhase = '' installPhase = ''
cp -r dist/* $out/ mkdir -p $out/${extDir}
cp metadata.json $out/ cp -r dist/* $out/${extDir}
''; '';
meta = { meta = {
@ -38,23 +44,18 @@
license = lib.licenses.gpl3Only; license = lib.licenses.gpl3Only;
maintainers = [lib.maintainers.quadradical]; maintainers = [lib.maintainers.quadradical];
}; };
}; });
# apps.build = { apps.install = {
# type = "app"; type = "app";
# program = pkgs.writeShellApplication { program = let
# name = "build"; file = "/tmp/${uuid}.zip";
# runtimeInputs = ; in
# text = let pkgs.writeShellScriptBin "build" ''
# name = "auto-rotate"; env -C ${self'.packages.default}/${extDir} ${lib.getExe pkgs.zip} ${file} -FS9r .
# in '' gnome-extensions install --force ${file}
# npm install '';
# tsc };
# cp metadata.json dist/
# env -C dist zip ../${name}.zip -9r .
# '';
# };
# };
}; };
}; };
} }

View file

@ -1,6 +1,7 @@
{ {
"compilerOptions": { "compilerOptions": {
"module": "NodeNext", "module": "NodeNext",
"skipLibCheck": true,
"moduleResolution": "NodeNext", "moduleResolution": "NodeNext",
"outDir": "./dist", "outDir": "./dist",
"sourceMap": false, "sourceMap": false,