Skip to content

Commit

Permalink
nix: flake & non-flake dev shells
Browse files Browse the repository at this point in the history
  • Loading branch information
max-ishere committed Aug 28, 2024
1 parent d2f4574 commit f9bb4d4
Show file tree
Hide file tree
Showing 8 changed files with 135 additions and 1 deletion.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,8 @@
#
# SPDX-License-Identifier: CC0-1.0

# Cargo
target/

# Nix
result/
2 changes: 1 addition & 1 deletion .reuse/dep5
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ Upstream-Name: ReGreet
Upstream-Contact: Harish Rajagopal <[email protected]>
Source: https://github.com/rharish101/ReGreet

Files: Cargo.lock
Files: Cargo.lock flake.lock
Copyright: 2022 Harish Rajagopal <[email protected]>
License: CC0-1.0
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,12 @@ pre-commit install
Now, pre-commit should ensure that the code passes all linters locally before committing.
This will save time when creating PRs, since these linters also run in CI, and thus fail code that hasn't been linted well.
### Nix/NixOS
Simply run `nix develop .#vscode --command code .` to get VS Code set up with all the extensions you need. The default shell doesnt have any text editors configred.
You can also use nix without flakes if you choose to.
### Demo mode
To aid development, a "demo" mode is included within ReGreet that runs ReGreet independent of greetd.
Simply run ReGreet as follows:
Expand Down
17 changes: 17 additions & 0 deletions default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# SPDX-FileCopyrightText: 2024 Harish Rajagopal <[email protected]>
#
# SPDX-License-Identifier: GPL-3.0-or-later
{pkgs ? import <nixpkgs> {}}: let
manifest = (pkgs.lib.importTOML ./Cargo.toml).package;
in
pkgs.rustPlatform.buildRustPackage rec {
pname = manifest.name;
inherit (manifest) version;
cargoLock.lockFile = ./Cargo.lock;
src = pkgs.lib.cleanSource ./.;

buildFeatures = ["gtk4_8"];

nativeBuildInputs = with pkgs; [pkg-config wrapGAppsHook4];
buildInputs = with pkgs; [glib gtk4 pango librsvg];
}
27 changes: 27 additions & 0 deletions flake.lock

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

41 changes: 41 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# SPDX-FileCopyrightText: 2024 Harish Rajagopal <[email protected]>
#
# SPDX-License-Identifier: GPL-3.0-or-later
{
description = "Dev tooling for ReGreet";

inputs = {
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
};

outputs = {
self,
nixpkgs,
}: let
supportedSystems = ["x86_64-linux"];
forAllSystems = nixpkgs.lib.genAttrs supportedSystems;
pkgsFor = nixpkgs.legacyPackages;
in {
formatter = forAllSystems (system: pkgsFor.${system}.alejandra);

packages = forAllSystems (system: let
pkgs = pkgsFor.${system};
in rec {
default = regreet;
regreet = pkgs.callPackage ./default.nix {inherit pkgs;};
});

devShells = forAllSystems (system: let
pkgs = pkgsFor.${system};
in {
default = pkgs.callPackage ./shell.nix {inherit pkgs;};

vscode = pkgs.callPackage ./nix/vscode-shell.nix {
pkgs = import nixpkgs {
inherit system;
config.allowUnfree = true;
};
};
});
};
}
20 changes: 20 additions & 0 deletions nix/vscode-shell.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# SPDX-FileCopyrightText: 2024 Harish Rajagopal <[email protected]>
#
# SPDX-License-Identifier: GPL-3.0-or-later
{pkgs ? import <nixpkgs> {}}:
pkgs.mkShell {
inputsFrom = [(pkgs.callPackage ../shell.nix {})];
buildInputs = with pkgs; [
(
vscode-with-extensions.override {
vscodeExtensions = with vscode-extensions; [
rust-lang.rust-analyzer
tamasfe.even-better-toml
bbenoist.nix

vscodevim.vim # you can disable this in extension settings if you want
];
}
)
];
}
19 changes: 19 additions & 0 deletions shell.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# SPDX-FileCopyrightText: 2024 Harish Rajagopal <[email protected]>
#
# SPDX-License-Identifier: GPL-3.0-or-later
{pkgs ? import <nixpkgs> {}}:
pkgs.mkShell {
inputsFrom = [(pkgs.callPackage ./default.nix {})];
buildInputs = with pkgs; [
rust-analyzer
rustfmt
clippy

pre-commit
];

shellHook = ''
echo "Installing pre commit hooks";
pre-commit install;
'';
}

0 comments on commit f9bb4d4

Please sign in to comment.