Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

flake: switch to flake-utils and treefmt-nix #279

Merged
merged 1 commit into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/format.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ jobs:
- uses: DeterminateSystems/magic-nix-cache-action@main
- name: Check formatting
run: |
nix fmt -- --check
nix fmt -- --ci
6 changes: 3 additions & 3 deletions README-template.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ is to add the input `github:nix-community/nixpkgs-xr` to your flake
and import the convenient NixOS module `nixpkgs-xr.nixosModules.nixpkgs-xr`.
See the example below.

> [!IMPORTANT]
> \[!IMPORTANT\]
> This module adds the Nixpkgs overlay as well as [the binary cache][binary-cache] for this repository.
> If you don't want the binary cache see [manual setup](#manually-setup-flake-overlay) below.

Expand Down Expand Up @@ -84,7 +84,7 @@ Assuming your NixOS configuration is right in your `flake.nix`, you can write th

### Traditional setup

Compatibility for traditional NixOS setups is provided using [flake-compat][flake-compat].
Compatibility for traditional NixOS setups is provided using [flake-compat].
You can just add the following snippet to your configuration:

```nix
Expand All @@ -102,7 +102,7 @@ in
}
```

You can also pin the tarball url using tools like [niv][niv].
You can also pin the tarball url using tools like [niv].

## Packages

Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ is to add the input `github:nix-community/nixpkgs-xr` to your flake
and import the convenient NixOS module `nixpkgs-xr.nixosModules.nixpkgs-xr`.
See the example below.

> [!IMPORTANT]
> \[!IMPORTANT\]
> This module adds the Nixpkgs overlay as well as [the binary cache][binary-cache] for this repository.
> If you don't want the binary cache see [manual setup](#manually-setup-flake-overlay) below.

Expand Down Expand Up @@ -84,7 +84,7 @@ Assuming your NixOS configuration is right in your `flake.nix`, you can write th

### Traditional setup

Compatibility for traditional NixOS setups is provided using [flake-compat][flake-compat].
Compatibility for traditional NixOS setups is provided using [flake-compat].
You can just add the following snippet to your configuration:

```nix
Expand All @@ -102,7 +102,7 @@ in
}
```

You can also pin the tarball url using tools like [niv][niv].
You can also pin the tarball url using tools like [niv].

## Packages

Expand Down
35 changes: 35 additions & 0 deletions development.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# SPDX-FileCopyrightText: 2024 Sefa Eyeoglu <contact@scrumplex.net>
#
# SPDX-License-Identifier: MIT
{
flake-utils,
nixpkgs,
self,
treefmt-nix,
...
}:
flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = nixpkgs.legacyPackages.${system};
inherit (pkgs.lib) mapAttrs' nameValuePair;

treefmtEval = treefmt-nix.lib.evalModule pkgs ./treefmt.nix;

devShellChecks = mapAttrs' (n: nameValuePair "devShell-${n}") self.devShells.${system};
in
{
devShells.default = pkgs.mkShellNoCC {
packages = [
pkgs.nvfetcher
pkgs.reuse
];
};

checks = devShellChecks // {
formatting = treefmtEval.config.build.check self;
};

formatter = treefmtEval.config.build.wrapper;
}
)
60 changes: 47 additions & 13 deletions flake.lock

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

31 changes: 13 additions & 18 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,21 @@

inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-parts = {
url = "github:hercules-ci/flake-parts";
inputs.nixpkgs-lib.follows = "nixpkgs";
};
flake-utils.url = "github:numtide/flake-utils";
flake-compat.url = "https://flakehub.com/f/edolstra/flake-compat/1.tar.gz";
treefmt-nix = {
url = "github:numtide/treefmt-nix";
inputs.nixpkgs.follows = "nixpkgs";
};
};

outputs =
inputs@{ flake-parts, ... }:
flake-parts.lib.mkFlake { inherit inputs; } {
systems = [
"x86_64-linux"
"aarch64-linux"
];
imports = [
./parts/checks.nix
./parts/dev.nix
./parts/module.nix
./parts/readme.nix
./pkgs
];
};
{ flake-utils, ... }@inputs:
flake-utils.lib.meld inputs [
./development.nix
./nixos
./pkgs
./pkgs/overlay.nix
./tools/update-readme.nix
];
}
12 changes: 2 additions & 10 deletions parts/module.nix → nixos/default.nix
Original file line number Diff line number Diff line change
@@ -1,28 +1,20 @@
# SPDX-FileCopyrightText: 2023 Sefa Eyeoglu <contact@scrumplex.net>
# SPDX-FileCopyrightText: 2024 Sefa Eyeoglu <contact@scrumplex.net>
#
# SPDX-License-Identifier: MIT
{ self, ... }:
{
flake.nixosModules.nixpkgs-xr =
nixosModules.nixpkgs-xr =
{ config, lib, ... }:
let
inherit (lib)
mkEnableOption
mkIf
mkOption
mkRemovedOptionModule
;
cfg = config.nixpkgs.xr;
in
{
imports = [
(mkRemovedOptionModule [
"nixpkgs"
"xr"
"enableUnstripped"
] "The nixpkgs-xr unstripped overlay has been removed. Please create your own overlay.")
];

options.nixpkgs.xr.enable = mkEnableOption "nixpkgs-xr overlay" // mkOption { default = true; };

config = mkIf cfg.enable {
Expand Down
20 changes: 10 additions & 10 deletions nvfetcher.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,25 @@
# SPDX-License-Identifier: CC0-1.0

[envision-unwrapped]
src.git = "https://gitlab.com/gabmus/envision.git"
cargo_locks = ["Cargo.lock"]
fetch.git = "https://gitlab.com/gabmus/envision.git"
src.git = "https://gitlab.com/gabmus/envision.git"

[index_camera_passthrough]
cargo_locks = ["Cargo.lock"]
fetch.git = "https://github.com/yshui/index_camera_passthrough.git"
src.git = "https://github.com/yshui/index_camera_passthrough.git"

[monado]
src.git = "https://gitlab.freedesktop.org/monado/monado.git"
fetch.git = "https://gitlab.freedesktop.org/monado/monado.git"
src.git = "https://gitlab.freedesktop.org/monado/monado.git"

[opencomposite]
src.git = "https://gitlab.com/znixian/OpenOVR.git"
fetch.git = "https://gitlab.com/znixian/OpenOVR.git"
git.fetchSubmodules = true

[index_camera_passthrough]
src.git = "https://github.com/yshui/index_camera_passthrough.git"
fetch.git = "https://github.com/yshui/index_camera_passthrough.git"
cargo_locks = ["Cargo.lock"]
src.git = "https://gitlab.com/znixian/OpenOVR.git"

[wlx-overlay-s]
src.git = "https://github.com/galister/wlx-overlay-s.git"
fetch.git = "https://github.com/galister/wlx-overlay-s.git"
cargo_locks = ["Cargo.lock"]
fetch.git = "https://github.com/galister/wlx-overlay-s.git"
src.git = "https://github.com/galister/wlx-overlay-s.git"
21 changes: 0 additions & 21 deletions parts/checks.nix

This file was deleted.

48 changes: 0 additions & 48 deletions parts/dev.nix

This file was deleted.

25 changes: 0 additions & 25 deletions parts/readme.nix

This file was deleted.

Loading
Loading