diff options
| author | Marcos Benevides <marcos.schonfinkel@gmail.com> | 2025-12-04 09:01:16 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-12-04 09:01:16 -0400 |
| commit | d4049e9cbb634bfedaea409ab0fdaee32a3b2282 (patch) | |
| tree | fc978654ff492fc2d88b0520303a734e7595cc22 | |
| parent | c4e1b573dacd67277ea9df1751574ef2dfb44601 (diff) | |
| download | Sakura-d4049e9cbb634bfedaea409ab0fdaee32a3b2282.tar.gz Sakura-d4049e9cbb634bfedaea409ab0fdaee32a3b2282.zip | |
#32 REFACTOR Nix setup (#33)
Diffstat (limited to '')
| -rw-r--r-- | flake.lock | 71 | ||||
| -rw-r--r-- | flake.nix | 84 | ||||
| -rw-r--r-- | treefmt.nix | 9 |
3 files changed, 134 insertions, 30 deletions
@@ -1,5 +1,23 @@ { "nodes": { + "flake-parts": { + "inputs": { + "nixpkgs-lib": "nixpkgs-lib" + }, + "locked": { + "lastModified": 1763759067, + "narHash": "sha256-LlLt2Jo/gMNYAwOgdRQBrsRoOz7BPRkzvNaI/fzXi2Q=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "2cccadc7357c0ba201788ae99c4dfa90728ef5e0", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, "nixpkgs": { "locked": { "lastModified": 1762363567, @@ -16,9 +34,60 @@ "type": "github" } }, + "nixpkgs-lib": { + "locked": { + "lastModified": 1761765539, + "narHash": "sha256-b0yj6kfvO8ApcSE+QmA6mUfu8IYG6/uU28OFn4PaC8M=", + "owner": "nix-community", + "repo": "nixpkgs.lib", + "rev": "719359f4562934ae99f5443f20aa06c2ffff91fc", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixpkgs.lib", + "type": "github" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1761236834, + "narHash": "sha256-+pthv6hrL5VLW2UqPdISGuLiUZ6SnAXdd2DdUE+fV2Q=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "d5faa84122bc0a1fd5d378492efce4e289f8eac1", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, "root": { "inputs": { - "nixpkgs": "nixpkgs" + "flake-parts": "flake-parts", + "nixpkgs": "nixpkgs", + "treefmt-nix": "treefmt-nix" + } + }, + "treefmt-nix": { + "inputs": { + "nixpkgs": "nixpkgs_2" + }, + "locked": { + "lastModified": 1762938485, + "narHash": "sha256-AlEObg0syDl+Spi4LsZIBrjw+snSVU4T8MOeuZJUJjM=", + "owner": "numtide", + "repo": "treefmt-nix", + "rev": "5b4ee75aeefd1e2d5a1cc43cf6ba65eba75e83e4", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "treefmt-nix", + "type": "github" } } }, @@ -1,36 +1,62 @@ { - description = "A very basic flake"; + description = "Domino's flakes"; inputs = { nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable"; - }; - outputs = { self, nixpkgs, ... }: - let - systems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ]; - forAllSystems = nixpkgs.lib.genAttrs systems; - in { - packages = forAllSystems (system: - let - pkgs = nixpkgs.legacyPackages.${system}; - in { - hello = pkgs.hello; - default = pkgs.hello; - } - ); - - devShells = forAllSystems (system: - let - pkgs = nixpkgs.legacyPackages.${system}; - in { - default = pkgs.mkShell { - packages = with pkgs; [ - erlang_28 - erlang-language-platform - rebar3 - ]; - }; - } - ); + flake-parts = { + url = "github:hercules-ci/flake-parts"; + }; + + treefmt-nix.url = "github:numtide/treefmt-nix"; }; + + outputs = + { self, + nixpkgs, + flake-parts, + treefmt-nix, + ... + }@inputs: + flake-parts.lib.mkFlake { inherit inputs; } { + systems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ]; + + perSystem = + { pkgs, system, ... }: + let + treefmtEval = treefmt-nix.lib.evalModule pkgs ./treefmt.nix; + in + { + # This sets `pkgs` to a nixpkgs with allowUnfree option set. + _module.args.pkgs = import nixpkgs { + inherit system; + config.allowUnfree = true; + }; + + # nix build + packages = { + hello = pkgs.hello; + default = pkgs.hello; + }; + + devShells = + { + default = pkgs.mkShell { + packages = with pkgs; [ + erlang_28 + erlang-language-platform + rebar3 + ]; + }; + }; + + # nix fmt + formatter = treefmtEval.config.build.wrapper; + + # nix flake check --all-systems + checks = { + formatting = treefmtEval.config.build.check self; + }; + }; + }; } diff --git a/treefmt.nix b/treefmt.nix new file mode 100644 index 0000000..4341016 --- /dev/null +++ b/treefmt.nix @@ -0,0 +1,9 @@ +# treefmt.nix +{ pkgs, ... }: +{ + # Used to find the project root + projectRootFile = "flake.nix"; + programs = { + erlfmt.enable = true; + }; +} |
