From 0959de9f4836a667968ff7e89287f812170b5040 Mon Sep 17 00:00:00 2001 From: 5225225 <5225225@mailbox.org> Date: Sat, 18 Oct 2025 15:40:01 +0000 Subject: [PATCH] add format.sh from labs, reformat tree (#18) Co-authored-by: Jake Hamilton Reviewed-on: https://git.auxolotl.org/auxolotl/foundation/pulls/18 Co-authored-by: 5225225 <5225225@mailbox.org> Co-committed-by: 5225225 <5225225@mailbox.org> --- default.nix | 4 ++-- flake.nix | 2 +- format.sh | 6 ++++++ src/builders/file/text/default.nix | 25 ++++++++++++------------- src/stages/stage1/gnumake/boot.nix | 3 ++- 5 files changed, 23 insertions(+), 17 deletions(-) create mode 100755 format.sh diff --git a/default.nix b/default.nix index 5c6fef5..5746eb8 100644 --- a/default.nix +++ b/default.nix @@ -2,8 +2,8 @@ system ? builtins.currentSystem, }: let - pins = import ./npins; - lib = import pins.lib; + pins = import ./npins; + lib = import pins.lib; modules = import ./src; diff --git a/flake.nix b/flake.nix index 13e5c43..8b63817 100644 --- a/flake.nix +++ b/flake.nix @@ -24,7 +24,7 @@ system: let result = lib.modules.run { - modules = (builtins.attrValues modules) ++ [{ config.aux.system = system; }]; + modules = (builtins.attrValues modules) ++ [ { config.aux.system = system; } ]; }; export = result: result.config.exports.resolved.packages // { extend = extend result; }; extend = result: overrides: export (result.extend overrides); diff --git a/format.sh b/format.sh new file mode 100755 index 0000000..8dce3e7 --- /dev/null +++ b/format.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env nix-shell +#!nix-shell -i bash -I "nixpkgs=https://github.com/nixos/nixpkgs/archive/nixos-unstable.tar.gz" -p nixfmt-rfc-style + +files=$(find . -name "*.nix" -type f) + +nixfmt ${1:-"--verify"} ${files} diff --git a/src/builders/file/text/default.nix b/src/builders/file/text/default.nix index ac34eda..d64cad5 100644 --- a/src/builders/file/text/default.nix +++ b/src/builders/file/text/default.nix @@ -25,19 +25,18 @@ in ... }: let - script = - '' - target=''${out}''${destination} - '' - + lib.strings.when (builtins.dirOf destination == ".") '' - mkdir -p ''${out}''${destinationDir} - '' - + '' - cp ''${contentsPath} ''${target} - '' - + lib.strings.when isExecutable '' - chmod 555 ''${target} - ''; + script = '' + target=''${out}''${destination} + '' + + lib.strings.when (builtins.dirOf destination == ".") '' + mkdir -p ''${out}''${destinationDir} + '' + + '' + cp ''${contentsPath} ''${target} + '' + + lib.strings.when isExecutable '' + chmod 555 ''${target} + ''; package = builtins.derivation ( (builtins.removeAttrs settings [ "meta" diff --git a/src/stages/stage1/gnumake/boot.nix b/src/stages/stage1/gnumake/boot.nix index 3518268..27431ae 100644 --- a/src/stages/stage1/gnumake/boot.nix +++ b/src/stages/stage1/gnumake/boot.nix @@ -126,7 +126,8 @@ in "-DNO_OUTPUT_SYNC=1" # mes-libc doesn't define O_TMPFILE "-DO_TMPFILE=020000000" - ] ++ config; + ] + ++ config; sources = { # Maintenance note: list of source files derived from Basic.mk