Skip to content

Commit

Permalink
build(nix): add flake
Browse files Browse the repository at this point in the history
  • Loading branch information
isabelroses authored and sgoudham committed Jun 3, 2024
1 parent 791ac97 commit 68f695d
Show file tree
Hide file tree
Showing 3 changed files with 132 additions and 24 deletions.
57 changes: 56 additions & 1 deletion flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

77 changes: 65 additions & 12 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -1,29 +1,82 @@
{
inputs.nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs = {
nixpkgs.follows = "nixpkgs";
};
};
};

outputs =
{ nixpkgs, ... }:
{
self,
nixpkgs,
rust-overlay,
...
}:
let
systems = [
"aarch64-darwin"
"aarch64-linux"
"x86_64-darwin"
"x86_64-linux"
];
forAllSystems =
function: nixpkgs.lib.genAttrs systems (system: function nixpkgs.legacyPackages.${system});
inherit (nixpkgs) lib;
forEachSystem =
f:
(lib.listToAttrs (
map (system: {
name = system;
value = f {
inherit system;
pkgs = import nixpkgs {
inherit system;
overlays = [ rust-overlay.overlays.default ];
};
};
}) systems
));
in
{
devShells = forAllSystems (pkgs: {
default = pkgs.callPackage ./shell.nix { };
});
devShells = forEachSystem (
{ pkgs, system }:
{
default = pkgs.mkShell {
inputsFrom = [ self.packages.${system}.default ];

packages = [
(pkgs.rust-bin.stable.latest.default.override {
extensions = [
"rustfmt"
"rust-analyzer"
"clippy"
];
})
];
};
}
);

packages = forAllSystems (pkgs: rec {
default = whiskers;
whiskers = pkgs.callPackage ./default.nix { };
});
packages = forEachSystem (
{ pkgs, system }:
{
default = self.packages.${system}.whiskers;
whiskers = pkgs.callPackage ./default.nix {
rustPlatform =
let
toolchain = pkgs.rust-bin.stable.latest.default;
in
pkgs.makeRustPlatform {
cargo = toolchain;
rustc = toolchain;
};
};
}
);

overlays.default = _: prev: { catppuccin-whiskers = prev.callPackage ./default.nix { }; };
overlays.default = final: _: { catppuccin-whiskers = final.callPackage ./default.nix { }; };
};

nixConfig = {
Expand Down
22 changes: 11 additions & 11 deletions shell.nix
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
{
clippy,
rustfmt,
callPackage,
rust-analyzer,
}:
{ callPackage, toolchain }:
let
mainPkg = callPackage ./default.nix { };
toolchainWithComponents = (
toolchain.stable.latest.default.override {
extensions = [
"rustfmt"
"rust-analyzer"
"clippy"
];
}
);
in
mainPkg.overrideAttrs (oa: {
nativeBuildInputs = [
clippy
rustfmt
rust-analyzer
] ++ (oa.nativeBuildInputs or [ ]);
nativeBuildInputs = [ toolchainWithComponents ] ++ (oa.nativeBuildInputs or [ ]);
})

0 comments on commit 68f695d

Please sign in to comment.