From c23487b544afa1845a0fefd1b28fdaa309bbc216 Mon Sep 17 00:00:00 2001 From: Daniel Flanagan Date: Tue, 30 Jul 2024 15:16:46 -0500 Subject: [PATCH] Slippi --- flake.lock | 119 +++++++++++++++++++++++++++++--------- flake.nix | 9 +-- nixos/dragon.nix | 2 +- templates/rust/.gitignore | 1 + templates/rust/flake.nix | 90 ++++++++++++++++++++-------- 5 files changed, 167 insertions(+), 54 deletions(-) diff --git a/flake.lock b/flake.lock index a907e46..b32708b 100644 --- a/flake.lock +++ b/flake.lock @@ -91,6 +91,22 @@ "type": "github" } }, + "flake-compat_2": { + "flake": false, + "locked": { + "lastModified": 1696426674, + "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, "flake-utils": { "inputs": { "systems": "systems" @@ -132,6 +148,30 @@ "type": "github" } }, + "git-hooks_2": { + "inputs": { + "flake-compat": "flake-compat_2", + "gitignore": "gitignore_2", + "nixpkgs": [ + "slippi", + "nixpkgs" + ], + "nixpkgs-stable": "nixpkgs-stable_2" + }, + "locked": { + "lastModified": 1721042469, + "narHash": "sha256-6FPUl7HVtvRHCCBQne7Ylp4p+dpP3P/OYuzjztZ4s70=", + "owner": "cachix", + "repo": "git-hooks.nix", + "rev": "f451c19376071a90d8c58ab1a953c6e9840527fd", + "type": "github" + }, + "original": { + "owner": "cachix", + "repo": "git-hooks.nix", + "type": "github" + } + }, "gitignore": { "inputs": { "nixpkgs": [ @@ -153,6 +193,28 @@ "type": "github" } }, + "gitignore_2": { + "inputs": { + "nixpkgs": [ + "slippi", + "git-hooks", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1709087332, + "narHash": "sha256-HG2cCnktfHsKV0s4XW83gU3F57gaTljL9KNSuG6bnQs=", + "owner": "hercules-ci", + "repo": "gitignore.nix", + "rev": "637db329424fd7e46cf4185293b9cc8c88c95394", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "gitignore.nix", + "type": "github" + } + }, "hardware": { "locked": { "lastModified": 1722017959, @@ -423,6 +485,22 @@ "type": "github" } }, + "nixpkgs-stable_2": { + "locked": { + "lastModified": 1720386169, + "narHash": "sha256-NGKVY4PjzwAa4upkGtAMz1npHGoRzWotlSnVlqI40mo=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "194846768975b7ad2c4988bdb82572c00222c0d7", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-24.05", + "repo": "nixpkgs", + "type": "github" + } + }, "nixpkgs-unstable": { "locked": { "lastModified": 1722040881, @@ -471,22 +549,6 @@ "type": "github" } }, - "nixpkgs_4": { - "locked": { - "lastModified": 1716769173, - "narHash": "sha256-7EXDb5WBw+d004Agt+JHC/Oyh/KTUglOaQ4MNjBbo5w=", - "owner": "nixos", - "repo": "nixpkgs", - "rev": "9ca3f649614213b2aaf5f1e16ec06952fe4c2632", - "type": "github" - }, - "original": { - "owner": "nixos", - "ref": "nixos-unstable", - "repo": "nixpkgs", - "type": "github" - } - }, "root": { "inputs": { "disko": "disko", @@ -529,20 +591,25 @@ }, "slippi": { "inputs": { - "nixpkgs": "nixpkgs_4" + "git-hooks": "git-hooks_2", + "home-manager": [ + "home-manager-unstable" + ], + "nixpkgs": [ + "nixpkgs-unstable" + ] }, "locked": { - "lastModified": 1721686199, - "narHash": "sha256-4rMu207y5HCLkRDbZXdFhFqAfDKxwCJ1r9UOsXmef4Q=", - "owner": "lytedev", - "repo": "slippi-nix", - "rev": "2b9673de8ec491be1c3ad8d23461b1fe5f2736b0", - "type": "github" + "dirtyRev": "5bfb7a3cc6c2bf124f5c1de080ee47b990674034-dirty", + "dirtyShortRev": "5bfb7a3-dirty", + "lastModified": 1722367638, + "narHash": "sha256-iUf05OQc/FejyhLgSfbYhAM3BDd/0TxSYe2XTF7atDU=", + "type": "git", + "url": "file:///home/daniel/code/open-source/slippi-nix" }, "original": { - "owner": "lytedev", - "repo": "slippi-nix", - "type": "github" + "type": "git", + "url": "file:///home/daniel/code/open-source/slippi-nix" } }, "sops-nix": { diff --git a/flake.nix b/flake.nix index c63f222..0672f1c 100644 --- a/flake.nix +++ b/flake.nix @@ -22,8 +22,10 @@ helix.url = "github:helix-editor/helix/master"; hardware.url = "github:nixos/nixos-hardware"; hyprland.url = "github:hyprwm/Hyprland"; - slippi.url = "github:lytedev/slippi-nix"; - # slippi.url = "git+file:///home/daniel/code/open-source/slippi-nix"; + # slippi.url = "github:lytedev/slippi-nix/fix-recursion"; + slippi.url = "git+file:///home/daniel/code/open-source/slippi-nix"; + slippi.inputs.nixpkgs.follows = "nixpkgs-unstable"; + slippi.inputs.home-manager.follows = "home-manager-unstable"; # nnf.url = "github:thelegy/nixos-nftables-firewall?rev=71fc2b79358d0dbacde83c806a0f008ece567b7b"; }; @@ -121,8 +123,7 @@ }: { default = mkShell { inherit (outputs.checks.${system}.git-hooks) shellHook; - - buildInputs = with pkgs; [ + packages = with pkgs; [ lua-language-server nodePackages.bash-language-server ]; diff --git a/nixos/dragon.nix b/nixos/dragon.nix index dea4433..53714ba 100644 --- a/nixos/dragon.nix +++ b/nixos/dragon.nix @@ -67,7 +67,7 @@ ]; home-manager.users.daniel = { - slippi.launcher = { + slippi-launcher = { enable = true; isoPath = "${config.home-manager.users.daniel.home.homeDirectory}/../games/roms/dolphin/melee.iso"; launchMeleeOnPlay = false; diff --git a/templates/rust/.gitignore b/templates/rust/.gitignore index 6abfe1b..228f69f 100644 --- a/templates/rust/.gitignore +++ b/templates/rust/.gitignore @@ -1,2 +1,3 @@ /target /.direnv +/.pre-commit-config.yaml diff --git a/templates/rust/flake.nix b/templates/rust/flake.nix index be6b512..f7c6efa 100644 --- a/templates/rust/flake.nix +++ b/templates/rust/flake.nix @@ -1,35 +1,79 @@ { - inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + git-hooks.url = "github:cachix/git-hooks.nix"; + git-hooks.inputs.nixpkgs.follows = "nixpkgs"; + }; outputs = { self, + git-hooks, nixpkgs, }: let inherit (self) outputs; - supportedSystems = [ - "x86_64-linux" - "aarch64-linux" - - "x86_64-darwin" - "aarch64-darwin" - ]; - forEachSupportedSystem = nixpkgs.lib.genAttrs supportedSystems; + systems = ["aarch64-linux" "aarch64-darwin" "x86_64-darwin" "x86_64-linux"]; + forSystems = nixpkgs.lib.genAttrs systems; + pkgsFor = system: (import nixpkgs {inherit system;}).extend outputs.overlays.default; + genPkgs = func: (forSystems (system: func (pkgsFor system))); in { - devShells = forEachSupportedSystem (system: let - pkgs = import nixpkgs {inherit system;}; - in { - rust-dev = pkgs.mkShell { - buildInputs = with pkgs; [ - cargo - rustc - rustfmt - rustPackages.clippy - rust-analyzer - lldb - pkg-config - ]; + checks = genPkgs (pkgs: { + git-hooks = git-hooks.lib.${pkgs.system}.run { + src = ./.; + hooks = { + alejandra.enable = true; + # NOTE: These do not work well with `nix flake check` due to pure environments + # https://github.com/cachix/git-hooks.nix/issues/452 + # cargo-check.enable = true; + # clippy = { + # enable = true; + # packageOverrides.cargo = pkgs.cargo; + # packageOverrides.clippy = pkgs.rustPackages.clippy; + # }; + rustfmt = { + enable = true; + packageOverrides.rustfmt = pkgs.rustfmt; + }; + }; + }; + }); + + packages = genPkgs (pkgs: { + my-package = pkgs.rustPlatform.buildRustPackage { + pname = "kodotag"; + version = "0.1.0"; + + # nativeBuildInputs = with pkgs; [ + # pkg-config + # clang + # ]; + + # buildInputs = with pkgs; [ + # ]; + + src = ./.; + hash = pkgs.lib.fakeHash; + cargoHash = "sha256-W7VQlMktGsRPQL9VGVmxYV6C5u2eJ48S7eTpOM+3n8U="; }; - default = outputs.devShells.${system}.rust-dev; + default = outputs.packages.${pkgs.system}.my-package; }); + + devShells = genPkgs (pkgs: { + default = pkgs.mkShell { + inherit (self.checks.${pkgs.system}.git-hooks) shellHook; + inputsFrom = [outputs.packages.${pkgs.system}.default]; + packages = with pkgs; [ + rustPackages.clippy + rust-analyzer + rustfmt + lldb + ]; + }; + }); + + overlays = { + default = final: prev: {}; + }; + + formatter = genPkgs (p: p.alejandra); }; }