diff --git a/.gitignore b/.gitignore index e0fbe03..3aede59 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ .direnv/ # nixago: ignore-linked-files +/rustfmt.toml /treefmt.toml /.prettierrc.json /lefthook.yml diff --git a/flake.lock b/flake.lock index d840ffc..3854b9f 100644 --- a/flake.lock +++ b/flake.lock @@ -1,19 +1,5 @@ { "nodes": { - "flake-schemas": { - "locked": { - "lastModified": 1697467827, - "narHash": "sha256-j8SR19V1SRysyJwpOBF4TLuAvAjF5t+gMiboN4gYQDU=", - "rev": "764932025c817d4e500a8d2a4d8c565563923d29", - "revCount": 29, - "type": "tarball", - "url": "https://api.flakehub.com/f/pinned/DeterminateSystems/flake-schemas/0.1.2/018b3da8-4cc3-7fbb-8ff7-1588413c53e2/source.tar.gz" - }, - "original": { - "type": "tarball", - "url": "https://flakehub.com/f/DeterminateSystems/flake-schemas/0.1.2.tar.gz" - } - }, "flake-utils": { "locked": { "lastModified": 1653893745, @@ -379,7 +365,6 @@ }, "root": { "inputs": { - "flake-schemas": "flake-schemas", "nixago": "nixago", "nixago-exts": "nixago-exts_3", "nixpkgs": "nixpkgs" diff --git a/flake.nix b/flake.nix index bdc807a..e3085eb 100644 --- a/flake.nix +++ b/flake.nix @@ -9,8 +9,6 @@ nixago-exts.url = "github:nix-community/nixago-extensions"; nixago-exts.inputs.nixpkgs.follows = "nixpkgs"; - - flake-schemas.url = "https://flakehub.com/f/DeterminateSystems/flake-schemas/0.1.2.tar.gz"; }; outputs = inputs @ { self, nixpkgs, nixago, nixago-exts, ... }: @@ -22,37 +20,41 @@ pkgs = import nixpkgs { inherit system; }; }); in + rec { - # The schemes we use. - schemas = inputs.flake-schemas.schemas; - - # Expose the configuration options for setup. - nixosModules = { - mfgames-project-setup = import ./src/modules/default.nix; - default = self.nixosModules.mfgames-project-setup; - }; - # Expose the configuration information. lib = { - sayHello = nixpkgs."x86_64-linux".lib.debug.traceVal (name: "Hello there, ${name}!"); + mkShellHook = + { system + , pkgs + , rust ? { } + , ... + }: + let + rustDefaults = { enable = false; }; + configs = import ./src/configs/default.nix { + inherit system pkgs nixago nixago-exts; + rust = rustDefaults // rust; + }; + in + '' + ${configs.shellHook} + ${pkgs.lefthook}/bin/lefthook install + ''; }; - configs = - forEachSupportedSystem ({ system, pkgs }: - (import ./src/configs/default.nix { inherit system pkgs nixago nixago-exts; })); - # Set up the developer shell. devShells = forEachSupportedSystem ({ system, pkgs }: let - configs = import ./src/configs/default.nix { inherit system pkgs nixago nixago-exts; }; + configShellHook = lib.mkShellHook { + inherit system pkgs; + #rust.enable = false; + }; in { # Shell default = pkgs.mkShell { - shellHook = '' - ${configs.shellHook} - lefthook install - ''; + shellHook = configShellHook; }; }); diff --git a/src/configs/default.nix b/src/configs/default.nix index 4d3f6db..2b9c4e1 100644 --- a/src/configs/default.nix +++ b/src/configs/default.nix @@ -1,9 +1,12 @@ -inputs: -inputs.nixago.lib.${inputs.system}.makeAll [ +inputs @ { pkgs, rust ? { enable = false; }, ... }: +let lib = pkgs.lib; in +inputs.nixago.lib.${inputs.system}.makeAll ([ (import ./conform.nix (inputs)) (import ./editorconfig.nix (inputs)) (import ./lefthook.nix (inputs)) (import ./prettier.nix (inputs)) - #(import ./rustfmt.nix (inputs)) (import ./treefmt.nix (inputs)) ] +++ lib.optionals rust.enable [ + (import ./rustfmt.nix (inputs)) +]) diff --git a/src/configs/rustfmt.nix b/src/configs/rustfmt.nix index 86a90ec..91eb2b1 100644 --- a/src/configs/rustfmt.nix +++ b/src/configs/rustfmt.nix @@ -1,4 +1,4 @@ -inputs: +inputs @ { pkgs, ... }: let data = { brace_style = "AlwaysNextLine"; diff --git a/src/configs/treefmt.nix b/src/configs/treefmt.nix index 04d3ba1..caed577 100644 --- a/src/configs/treefmt.nix +++ b/src/configs/treefmt.nix @@ -1,4 +1,4 @@ -inputs @ { pkgs, ... }: +inputs @ { pkgs, rust, ... }: let data = { formatter = { @@ -24,7 +24,8 @@ let ]; excludes = [ "**.min.js" ]; }; - + } + // pkgs.lib.attrsets.optionalAttrs rust.enable { rust = { command = "rustfmt"; options = [ "--edition" "2021" ]; diff --git a/src/modules/default.nix b/src/modules/default.nix deleted file mode 100644 index 58c8cf9..0000000 --- a/src/modules/default.nix +++ /dev/null @@ -1,23 +0,0 @@ -{ config, lib, pkgs, ... }: -let - cfg = config.mfgames-project-setup; - secretType = types.submodule ({ config, ... }: { - options = { - rust = mkOption { - type = types.bool; - default = false; - }; - }; - }); -in -{ - options.mfgames-project-setup = { - rust = mkOption { - type = types.bool; - default = true; - description = '' - Enabling this option including tools for handling Rust projects. - ''; - }; - }; -}