Format with alejandra

This commit is contained in:
Sam W 2022-06-19 15:20:35 +01:00
parent c5efaa6024
commit 06ffebaddc
4 changed files with 78 additions and 56 deletions

View File

@ -4,14 +4,20 @@
utils.url = "github:numtide/flake-utils"; utils.url = "github:numtide/flake-utils";
devshell.url = "github:numtide/devshell"; devshell.url = "github:numtide/devshell";
}; };
outputs = { self, nixpkgs, utils, devshell }: outputs = {
self,
nixpkgs,
utils,
devshell,
}:
utils.lib.eachDefaultSystem (system: { utils.lib.eachDefaultSystem (system: {
devShells.default = let devShells.default = let
pkgs = import nixpkgs { pkgs = import nixpkgs {
inherit system; inherit system;
overlays = [ devshell.overlay ]; overlays = [devshell.overlay];
}; };
in pkgs.devshell.mkShell { packages = with pkgs; [ ]; }; in
pkgs.devshell.mkShell {packages = with pkgs; [];};
}); });
} }

View File

@ -1,8 +1,12 @@
{ {
description = "Samw's Nix flake templates"; description = "Samw's Nix flake templates";
inputs = { utils.url = "github:numtide/flake-utils"; }; inputs = {utils.url = "github:numtide/flake-utils";};
outputs = { self, utils, nixpkgs }: outputs = {
self,
utils,
nixpkgs,
}:
{ {
templates = { templates = {
rust = { rust = {
@ -18,7 +22,8 @@
description = "A basic devshell setup"; description = "A basic devshell setup";
}; };
}; };
} // utils.lib.eachDefaultSystem (system: }
let pkgs = import nixpkgs { inherit system; }; // utils.lib.eachDefaultSystem (system: let
in { formatter = pkgs.nixfmt; }); pkgs = import nixpkgs {inherit system;};
in {formatter = pkgs.alejandra;});
} }

View File

@ -7,28 +7,32 @@
inputs.flake-utils.follows = "flake-utils"; inputs.flake-utils.follows = "flake-utils";
}; };
outputs = { self, nixpkgs, utils, devshell }: outputs = {
utils.lib.eachDefaultSystem (system: self,
let nixpkgs,
pkgs = import nixpkgs { utils,
inherit system; devshell,
overlays = [ devshell.overlay ]; }:
}; utils.lib.eachDefaultSystem (system: let
in rec { pkgs = import nixpkgs {
packages.default = pkgs.buildGoModule { inherit system;
name = "my-project"; overlays = [devshell.overlay];
src = self; };
vendorSha256 = ""; in rec {
packages.default = pkgs.buildGoModule {
name = "my-project";
src = self;
vendorSha256 = "";
# Inject the git version if you want # Inject the git version if you want
#ldflags = '' #ldflags = ''
# -X main.version=${if self ? rev then self.rev else "dirty"} # -X main.version=${if self ? rev then self.rev else "dirty"}
#''; #'';
}; };
apps.default = utils.lib.mkApp { drv = packages.default; }; apps.default = utils.lib.mkApp {drv = packages.default;};
devShells.default = devShells.default =
pkgs.devshell.mkShell { packages = with pkgs; [ go gopls ]; }; pkgs.devshell.mkShell {packages = with pkgs; [go gopls];};
}); });
} }

View File

@ -8,35 +8,42 @@
rust-overlay.url = "github:oxalica/rust-overlay"; rust-overlay.url = "github:oxalica/rust-overlay";
}; };
outputs = { self, nixpkgs, utils, naersk, devshell, rust-overlay }: outputs = {
utils.lib.eachDefaultSystem (system: self,
let nixpkgs,
utils,
naersk,
devshell,
rust-overlay,
}:
utils.lib.eachDefaultSystem (system: let
pkgs = import nixpkgs {
inherit system;
overlays = [(import rust-overlay)];
};
rust = pkgs.rust-bin.stable.latest.default;
# Override naersk to use our chosen rust version from rust-overlay
naersk-lib = naersk.lib.${system}.override {
cargo = rust;
rustc = rust;
};
in rec {
packages.default = naersk-lib.buildPackage {
pname = "cool-rust-disaster";
root = ./.;
};
apps.default = utils.lib.mkApp {drv = packages.default;};
# Provide a dev env with rust and rls
devShells.default = let
pkgs = import nixpkgs { pkgs = import nixpkgs {
inherit system; inherit system;
overlays = [ (import rust-overlay) ]; overlays = [devshell.overlay];
}; };
rust = pkgs.rust-bin.stable.latest.default; in
# Override naersk to use our chosen rust version from rust-overlay pkgs.devshell.mkShell {
naersk-lib = naersk.lib.${system}.override { packages = with pkgs; [(rust.override {extensions = ["rls"];})];
cargo = rust;
rustc = rust;
}; };
in rec { });
packages.default = naersk-lib.buildPackage {
pname = "cool-rust-disaster";
root = ./.;
};
apps.default = utils.lib.mkApp { drv = packages.default; };
# Provide a dev env with rust and rls
devShells.default = let
pkgs = import nixpkgs {
inherit system;
overlays = [ devshell.overlay ];
};
in pkgs.devshell.mkShell {
packages = with pkgs; [ (rust.override { extensions = [ "rls" ]; }) ];
};
});
} }