From a0656abe2f890c4e6d75eceabd27e24b53772007 Mon Sep 17 00:00:00 2001 From: Ingolf Wagner Date: Fri, 15 Nov 2024 21:15:35 +0700 Subject: [PATCH] :tada: init --- flake.lock | 79 +++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 47 ++++++++++++++++++++++++++++ nix/devshells.nix | 14 +++++++++ nix/formatter.nix | 13 ++++++++ 4 files changed, 153 insertions(+) create mode 100644 flake.lock create mode 100644 flake.nix create mode 100644 nix/devshells.nix create mode 100644 nix/formatter.nix diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..4a82b82 --- /dev/null +++ b/flake.lock @@ -0,0 +1,79 @@ +{ + "nodes": { + "flake-parts": { + "inputs": { + "nixpkgs-lib": "nixpkgs-lib" + }, + "locked": { + "lastModified": 1730504689, + "narHash": "sha256-hgmguH29K2fvs9szpq2r3pz2/8cJd2LPS+b4tfNFCwE=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "506278e768c2a08bec68eb62932193e341f55c90", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1731319897, + "narHash": "sha256-PbABj4tnbWFMfBp6OcUK5iGy1QY+/Z96ZcLpooIbuEI=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "dc460ec76cbff0e66e269457d7b728432263166c", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-lib": { + "locked": { + "lastModified": 1730504152, + "narHash": "sha256-lXvH/vOfb4aGYyvFmZK/HlsNsr/0CVWlwYvo2rxJk3s=", + "type": "tarball", + "url": "https://github.com/NixOS/nixpkgs/archive/cc2f28000298e1269cea6612cd06ec9979dd5d7f.tar.gz" + }, + "original": { + "type": "tarball", + "url": "https://github.com/NixOS/nixpkgs/archive/cc2f28000298e1269cea6612cd06ec9979dd5d7f.tar.gz" + } + }, + "root": { + "inputs": { + "flake-parts": "flake-parts", + "nixpkgs": "nixpkgs", + "treefmt-nix": "treefmt-nix" + } + }, + "treefmt-nix": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1730321837, + "narHash": "sha256-vK+a09qq19QNu2MlLcvN4qcRctJbqWkX7ahgPZ/+maI=", + "owner": "numtide", + "repo": "treefmt-nix", + "rev": "746901bb8dba96d154b66492a29f5db0693dbfcc", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "treefmt-nix", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..591fb47 --- /dev/null +++ b/flake.nix @@ -0,0 +1,47 @@ +{ + description = "My Dwarf Fortress DFHack files"; + + inputs = { + flake-parts.url = "github:hercules-ci/flake-parts"; + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + treefmt-nix.url = "github:numtide/treefmt-nix"; + treefmt-nix.inputs.nixpkgs.follows = "nixpkgs"; + }; + + outputs = + inputs@{ flake-parts, ... }: + flake-parts.lib.mkFlake { inherit inputs; } { + imports = [ + ./nix/formatter.nix + ./nix/devshells.nix + ]; + systems = [ + "x86_64-linux" + "aarch64-linux" + "aarch64-darwin" + "x86_64-darwin" + ]; + perSystem = + { + config, + self', + inputs', + pkgs, + system, + ... + }: + { + # Per-system attributes can be defined here. The self' and inputs' + # module parameters provide easy access to attributes of the same + # system. + + # Equivalent to inputs'.nixpkgs.legacyPackages.hello; + packages.default = pkgs.hello; + }; + flake = { + # The usual flake attributes can be defined here, including system- + # agnostic ones like nixosModule and system-enumerating ones, although + # those are more easily expressed in perSystem. + }; + }; +} diff --git a/nix/devshells.nix b/nix/devshells.nix new file mode 100644 index 0000000..a1ecd87 --- /dev/null +++ b/nix/devshells.nix @@ -0,0 +1,14 @@ +_: { + perSystem = + { pkgs, self', ... }: + { + devShells = { + default = pkgs.mkShell { + inputsFrom = [ self'.packages.default ]; + packages = [ + self'.formatter.outPath + ]; + }; + }; + }; +} diff --git a/nix/formatter.nix b/nix/formatter.nix new file mode 100644 index 0000000..47beaeb --- /dev/null +++ b/nix/formatter.nix @@ -0,0 +1,13 @@ +{ inputs, ... }: +{ + imports = [ inputs.treefmt-nix.flakeModule ]; + + perSystem = _: { + treefmt = { + # https://flake.parts/options/treefmt-nix < for all options + projectRootFile = ".git/config"; + programs.nixfmt.enable = true; + programs.biome.enable = true; + }; + }; +}