Skip to content

Commit

Permalink
flake: switch to flake-utils and treefmt-nix
Browse files Browse the repository at this point in the history
Signed-off-by: Sefa Eyeoglu <contact@scrumplex.net>
  • Loading branch information
Scrumplex committed Dec 6, 2024
1 parent ea93611 commit 4bd18ed
Show file tree
Hide file tree
Showing 14 changed files with 212 additions and 189 deletions.
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
18 changes: 9 additions & 9 deletions nvfetcher.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@
#
# SPDX-License-Identifier: CC0-1.0

[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

0 comments on commit 4bd18ed

Please sign in to comment.