-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Added nix stuff - Documented usage of nix stuff - Moved #contributing to a separate file
- Loading branch information
1 parent
9ff3e11
commit 71a85e8
Showing
14 changed files
with
314 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,11 @@ | |
# | ||
# SPDX-License-Identifier: CC0-1.0 | ||
|
||
# Cargo | ||
target/ | ||
|
||
# Nix | ||
result | ||
|
||
# fakegreet | ||
greetd.sock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<!-- | ||
SPDX-FileCopyrightText: 2024 Harish Rajagopal <harish.rajagopals@gmail.com> | ||
SPDX-License-Identifier: GPL-3.0-or-later | ||
--> | ||
|
||
# Contributing | ||
|
||
## Pre commit | ||
|
||
[pre-commit](https://pre-commit.com/) is used for managing hooks that run before each commit (such as clippy), to ensure | ||
code quality. Thus, this needs to be set up only when one intends to commit changes to git. | ||
|
||
Firstly, [install pre-commit](https://pre-commit.com/#installation) itself. Next, install pre-commit hooks: | ||
```sh | ||
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 dev shells | ||
|
||
Simply run `nix develop .#vscode --command code .` to get VS Code set up with all the extensions you need. The default | ||
shell doesn't have any text editors configred. | ||
|
||
You can also use nix without flakes if you choose to. See the [nix documentation in this repo](nix/README.md) for more | ||
details. | ||
|
||
## Testing | ||
|
||
You can run ReGreet without a greetd socket using `--demo` flag. It also disables some of the features such as logging | ||
to a file. | ||
|
||
```sh | ||
regreet --demo | ||
``` | ||
|
||
Since the demo mode doesn't use greetd, authentication is done using hardcoded credentials within the codebase. These | ||
credentials are logged with the warning log level, so that you don't have to read the source code. | ||
|
||
----- | ||
|
||
Alternatively you can use `fakegreet` to emulate a running greetd daemon. Please keep in mind that it's behavior doesn't | ||
match the real thing. | ||
|
||
```sh | ||
fakegreet 'cargo run' | ||
``` | ||
|
||
Fakegreet credentials (taken from source code): | ||
|
||
||Value| | ||
|---|---| | ||
|User|user| | ||
|Password|password| | ||
|7+2|9| |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# SPDX-FileCopyrightText: 2024 Harish Rajagopal <harish.rajagopals@gmail.com> | ||
# | ||
# SPDX-License-Identifier: GPL-3.0-or-later | ||
{pkgs ? import <nixpkgs> {}}: | ||
pkgs.callPackage ./nix/packages {} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# SPDX-FileCopyrightText: 2024 Harish Rajagopal <harish.rajagopals@gmail.com> | ||
# | ||
# 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 = system: | ||
import nixpkgs { | ||
config.allowUnfree = true; | ||
inherit system; | ||
}; | ||
in { | ||
formatter = forAllSystems (system: (pkgsFor system).alejandra); | ||
|
||
packages = forAllSystems (system: let | ||
pkgs = pkgsFor system; | ||
in | ||
{ | ||
default = self.packages.${system}.regreet; | ||
} | ||
// (pkgs.callPackage ./nix/packages {})); | ||
|
||
devShells = forAllSystems (system: let | ||
pkgs = pkgsFor system; | ||
in | ||
{ | ||
default = self.devShells.${system}.rust; | ||
} | ||
// (pkgs.callPackage ./nix/shells {})); | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<!-- | ||
SPDX-FileCopyrightText: 2024 Harish Rajagopal <harish.rajagopals@gmail.com> | ||
SPDX-License-Identifier: GPL-3.0-or-later | ||
--> | ||
|
||
# Nix | ||
|
||
## Structure | ||
|
||
|Path|| | ||
|---|---| | ||
|[`/nix/packages`](packages)|Filenames are keys in both `flake.packages` and attributes in [`/default.nix`](../default.nix)| | ||
|[`/nix/shells`](shells)|Filenames are keys in both `flake.devShells` and attributes in [`/shell.nix`](../shell.nix)| | ||
|
||
## Loading a shell / building packages | ||
|
||
<details><summary>With flakes</summary> | ||
|
||
See the flake source for what `.#default` points to. | ||
|
||
```sh | ||
nix develop .#<filename> | ||
nix build .#<filename> | ||
|
||
# Example | ||
|
||
nix develop .#vscode | ||
# Loads ./shells/vscode.nix | ||
``` | ||
|
||
</details> | ||
|
||
----- | ||
|
||
<details><summary>Without flakes</summary> | ||
|
||
You have to select an attribute with `-A`. `default` is not set (it doesnt work like that in `nix-*` commnands)! | ||
|
||
```sh | ||
nix-shell -A <filename> | ||
nix-build -A <filename> | ||
|
||
# Example | ||
|
||
nix-build -A regreet | ||
# Builds ./packages/regreet.nix | ||
``` | ||
|
||
</details> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# SPDX-FileCopyrightText: 2024 Harish Rajagopal <harish.rajagopals@gmail.com> | ||
# | ||
# SPDX-License-Identifier: GPL-3.0-or-later | ||
{ | ||
lib, | ||
callPackage, | ||
}: let | ||
inherit (builtins) map listToAttrs filter attrNames readDir; | ||
inherit (lib) removeSuffix; | ||
|
||
ls = attrNames (readDir ./.); | ||
notThisFile = name: name != "default.nix"; | ||
rmDotNix = removeSuffix ".nix"; | ||
mkAttr = file: { | ||
name = rmDotNix file; | ||
value = callPackage ./${file} {}; | ||
}; | ||
in | ||
listToAttrs (map mkAttr (filter notThisFile ls)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# SPDX-FileCopyrightText: 2024 Harish Rajagopal <harish.rajagopals@gmail.com> | ||
# | ||
# SPDX-License-Identifier: GPL-3.0-or-later | ||
{ | ||
buildFeatures ? ["gtk4_8"], | ||
lib, | ||
rustPlatform, | ||
pkg-config, | ||
wrapGAppsHook4, | ||
glib, | ||
gtk4, | ||
pango, | ||
librsvg, | ||
}: let | ||
manifest = (lib.importTOML ../../Cargo.toml).package; | ||
in | ||
rustPlatform.buildRustPackage rec { | ||
pname = manifest.name; | ||
inherit (manifest) version; | ||
cargoLock.lockFile = ../../Cargo.lock; | ||
src = lib.cleanSource ../..; | ||
|
||
inherit buildFeatures; | ||
|
||
nativeBuildInputs = [pkg-config wrapGAppsHook4]; | ||
buildInputs = [glib gtk4 pango librsvg]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# SPDX-FileCopyrightText: 2024 Harish Rajagopal <harish.rajagopals@gmail.com> | ||
# | ||
# SPDX-License-Identifier: GPL-3.0-or-later | ||
{ | ||
lib, | ||
callPackage, | ||
}: let | ||
inherit (builtins) map listToAttrs filter attrNames readDir; | ||
inherit (lib) removeSuffix; | ||
|
||
ls = attrNames (readDir ./.); | ||
notThisFile = name: name != "default.nix"; | ||
rmDotNix = removeSuffix ".nix"; | ||
mkAttr = file: { | ||
name = rmDotNix file; | ||
value = callPackage ./${file} {}; | ||
}; | ||
in | ||
listToAttrs (map mkAttr (filter notThisFile ls)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# SPDX-FileCopyrightText: 2024 Harish Rajagopal <harish.rajagopals@gmail.com> | ||
# | ||
# SPDX-License-Identifier: GPL-3.0-or-later | ||
{ | ||
callPackage, | ||
mkShell, | ||
rust-analyzer, | ||
rustfmt, | ||
clippy, | ||
pre-commit, | ||
greetd, | ||
}: | ||
mkShell { | ||
inputsFrom = [(callPackage ../packages/regreet.nix {})]; | ||
buildInputs = [ | ||
rust-analyzer | ||
rustfmt | ||
clippy | ||
|
||
pre-commit | ||
|
||
greetd.greetd # fakegreet | ||
]; | ||
|
||
shellHook = '' | ||
echo "Installing pre commit hooks"; | ||
pre-commit install; | ||
''; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# SPDX-FileCopyrightText: 2024 Harish Rajagopal <harish.rajagopals@gmail.com> | ||
# | ||
# SPDX-License-Identifier: GPL-3.0-or-later | ||
{ | ||
callPackage, | ||
mkShell, | ||
vscode-with-extensions, | ||
vscode-extensions, | ||
}: | ||
mkShell { | ||
inputsFrom = [(callPackage ./rust.nix {})]; | ||
buildInputs = [ | ||
( | ||
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 | ||
]; | ||
} | ||
) | ||
]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# SPDX-FileCopyrightText: 2024 Harish Rajagopal <harish.rajagopals@gmail.com> | ||
# | ||
# SPDX-License-Identifier: GPL-3.0-or-later | ||
{pkgs ? import <nixpkgs> {config.allowUnfree = true;}}: | ||
pkgs.callPackage ./nix/shells {} |