Skip to content

Commit

Permalink
Reformat using nixfmt
Browse files Browse the repository at this point in the history
  • Loading branch information
kuruczgy committed Dec 16, 2024
1 parent 5c4334e commit 00d8bd3
Show file tree
Hide file tree
Showing 12 changed files with 148 additions and 73 deletions.
44 changes: 23 additions & 21 deletions default.nix
Original file line number Diff line number Diff line change
@@ -1,26 +1,28 @@
{
nixosModules.x1e = { lib, pkgs, ... }: {
imports = [
./modules/x1e80100.nix
./modules/pd-mapper.nix
];
config = {
nixpkgs.overlays = [
(import ./packages/overlay.nix)
(final: prev: {
sway-unwrapped = prev.sway-unwrapped.overrideAttrs (old: {
patches = old.patches ++ [
# https://github.com/swaywm/sway/pull/8469
(pkgs.fetchpatch {
url = "https://github.com/swaywm/sway/commit/eee930a4a0d3bf0de2235661227bf1a827edd320.patch";
hash = "sha256-1aiU4GM/OTqhJElvMecGgNbpuGbVLyhkjwC91K/eMsU=";
})
];
});
})
nixosModules.x1e =
{ lib, pkgs, ... }:
{
imports = [
./modules/x1e80100.nix
./modules/pd-mapper.nix
];
config = {
nixpkgs.overlays = [
(import ./packages/overlay.nix)
(final: prev: {
sway-unwrapped = prev.sway-unwrapped.overrideAttrs (old: {
patches = old.patches ++ [
# https://github.com/swaywm/sway/pull/8469
(pkgs.fetchpatch {
url = "https://github.com/swaywm/sway/commit/eee930a4a0d3bf0de2235661227bf1a827edd320.patch";
hash = "sha256-1aiU4GM/OTqhJElvMecGgNbpuGbVLyhkjwC91K/eMsU=";
})
];
});
})
];

hardware.deviceTree.name = lib.mkDefault "qcom/x1e80100-lenovo-yoga-slim7x.dtb";
hardware.deviceTree.name = lib.mkDefault "qcom/x1e80100-lenovo-yoga-slim7x.dtb";
};
};
};
}
5 changes: 4 additions & 1 deletion examples/flake-based-config/configuration.nix
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@
isNormalUser = true;
# Default password, should be changed using `passwd` after first login.
password = "nixos";
extraGroups = [ "wheel" "networkmanager" ];
extraGroups = [
"wheel"
"networkmanager"
];
};

security.sudo.wheelNeedsPassword = false;
Expand Down
47 changes: 28 additions & 19 deletions examples/flake-based-config/flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,36 @@
x1e-nixos-config.url = "github:kuruczgy/x1e-nixos-config";
x1e-nixos-config.inputs.nixpkgs.follows = "nixpkgs";
};
outputs = { self, nixpkgs, x1e-nixos-config }: {
# Change "system" to your chosen hostname here:
nixosConfigurations.system = nixpkgs.lib.nixosSystem {
modules = [
x1e-nixos-config.nixosModules.x1e
{
networking.hostName = "system";
hardware.deviceTree.name = "qcom/x1e80100-lenovo-yoga-slim7x.dtb";
outputs =
{
self,
nixpkgs,
x1e-nixos-config,
}:
{
# Change "system" to your chosen hostname here:
nixosConfigurations.system = nixpkgs.lib.nixosSystem {
modules = [
x1e-nixos-config.nixosModules.x1e
{
networking.hostName = "system";
hardware.deviceTree.name = "qcom/x1e80100-lenovo-yoga-slim7x.dtb";

nixpkgs.hostPlatform.system = "aarch64-linux";
nixpkgs.hostPlatform.system = "aarch64-linux";

# Uncomment this to allow unfree packages.
# nixpkgs.config.allowUnfree = true;
# Uncomment this to allow unfree packages.
# nixpkgs.config.allowUnfree = true;

nix = {
channel.enable = false;
settings.experimental-features = [ "nix-command" "flakes" ];
};
}
./configuration.nix
];
nix = {
channel.enable = false;
settings.experimental-features = [
"nix-command"
"flakes"
];
};
}
./configuration.nix
];
};
};
};
}
36 changes: 25 additions & 11 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@
treefmt-nix.url = "github:numtide/treefmt-nix";
treefmt-nix.inputs.nixpkgs.follows = "nixpkgs";
};
outputs = { self, nixpkgs, treefmt-nix }:
outputs =
{
self,
nixpkgs,
treefmt-nix,
}:
let
# Modify this if you are building on something other than x86_64-linux.
buildSystem = "x86_64-linux";
Expand All @@ -15,14 +20,18 @@
deviceTreeName = "qcom/x1e80100-lenovo-yoga-slim7x.dtb";

nixpkgs-patched =
let pkgs-unpatched = nixpkgs.legacyPackages.${buildSystem}; in (pkgs-unpatched.applyPatches {
let
pkgs-unpatched = nixpkgs.legacyPackages.${buildSystem};
in
(pkgs-unpatched.applyPatches {
name = "nixpkgs-patched";
src = nixpkgs;
patches = [
./nixpkgs-devicetree.patch
./nixpkgs-efi-shell.patch
];
}).overrideAttrs { allowSubstitutes = true; };
}).overrideAttrs
{ allowSubstitutes = true; };

pkgs-cross = import nixpkgs-patched {
overlays = [ (import ./packages/overlay.nix) ];
Expand All @@ -31,7 +40,8 @@
allowUnsupportedSystem = true;
};
in
(import ./default.nix) // {
(import ./default.nix)
// {
nixosConfigurations = {
iso = nixpkgs.lib.nixosSystem {
modules = [
Expand All @@ -53,14 +63,17 @@
./examples/flake-based-config/configuration.nix
self.nixosModules.x1e
./modules/common.nix
({ lib, ... }: {
nixpkgs.pkgs = nixpkgs.legacyPackages.aarch64-linux;
hardware.deviceTree.name = deviceTreeName;
(
{ lib, ... }:
{
nixpkgs.pkgs = nixpkgs.legacyPackages.aarch64-linux;
hardware.deviceTree.name = deviceTreeName;

# Copy the cross-compiled kernel from the install ISO. Remove
# this if you want to natively compile the kernel on your device.
boot.kernelPackages = lib.mkForce pkgs-cross.x1e80100-linux;
})
# Copy the cross-compiled kernel from the install ISO. Remove
# this if you want to natively compile the kernel on your device.
boot.kernelPackages = lib.mkForce pkgs-cross.x1e80100-linux;
}
)
];
};
};
Expand All @@ -75,6 +88,7 @@
system:
(treefmt-nix.lib.evalModule nixpkgs.legacyPackages.${system} {
programs.nixfmt.enable = true;
settings.on-unmatched = "info";
})
);
in
Expand Down
10 changes: 8 additions & 2 deletions iso.nix
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,14 @@

# Add this repo to the flake registry.
nix.registry.x1e-nixos-config = {
from = { type = "indirect"; id = "x1e-nixos-config"; };
to = { type = "path"; path = ./.; };
from = {
type = "indirect";
id = "x1e-nixos-config";
};
to = {
type = "path";
path = ./.;
};
};

# Include this repo in the image
Expand Down
5 changes: 4 additions & 1 deletion modules/common.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
{
nix = {
channel.enable = false;
settings.experimental-features = [ "nix-command" "flakes" ];
settings.experimental-features = [
"nix-command"
"flakes"
];
};
}
14 changes: 12 additions & 2 deletions packages/libqrtr.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
{ stdenv, fetchFromGitHub, pkg-config, meson, ninja }:
{
stdenv,
fetchFromGitHub,
pkg-config,
meson,
ninja,
}:

stdenv.mkDerivation {
name = "libqrtr";
Expand All @@ -8,6 +14,10 @@ stdenv.mkDerivation {
rev = "ef44ad10f284410e2db4c4ce22c8645f988f8402";
hash = "sha256-9e40hidUqzQqDTmlUNpw5jsLduSzTO9bK/A1CTaBi2Y=";
};
nativeBuildInputs = [ pkg-config meson ninja ];
nativeBuildInputs = [
pkg-config
meson
ninja
];
mesonFlags = [ "-Dsystemd-service=disabled" ];
}
8 changes: 6 additions & 2 deletions packages/overlay.nix
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
final: prev: {
x1e80100-linux = final.callPackage ./x1e80100-linux.nix { };
x1e80100-lenovo-yoga-slim7x-firmware = final.callPackage ./x1e80100-lenovo-yoga-slim7x-firmware.nix { };
x1e80100-lenovo-yoga-slim7x-firmware-json = final.callPackage ./x1e80100-lenovo-yoga-slim7x-firmware-json.nix { };
x1e80100-lenovo-yoga-slim7x-firmware =
final.callPackage ./x1e80100-lenovo-yoga-slim7x-firmware.nix
{ };
x1e80100-lenovo-yoga-slim7x-firmware-json =
final.callPackage ./x1e80100-lenovo-yoga-slim7x-firmware-json.nix
{ };
libqrtr = final.callPackage ./libqrtr.nix { };
pd-mapper = final.callPackage ./pd-mapper.nix { };
}
17 changes: 14 additions & 3 deletions packages/pd-mapper.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
{ stdenv, fetchFromGitHub, libqrtr, xz }:
{
stdenv,
fetchFromGitHub,
libqrtr,
xz,
}:

stdenv.mkDerivation {
name = "pd-mapper";
Expand All @@ -11,6 +16,12 @@ stdenv.mkDerivation {
patchPhase = ''
sed -i "s|/lib/firmware/|/run/current-system/firmware/|g" pd-mapper.c
'';
buildInputs = [ libqrtr xz ];
makeFlags = [ "DESTDIR=$(out)" "prefix=" ];
buildInputs = [
libqrtr
xz
];
makeFlags = [
"DESTDIR=$(out)"
"prefix="
];
}
19 changes: 10 additions & 9 deletions packages/x1e80100-lenovo-yoga-slim7x-firmware-json.nix
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
{ runCommand }:

runCommand "x1e80100-lenovo-yoga-slim7x-firmware-json"
{
# The userspace pd-mapper daemon cannot handle zstd compressed firmware, so
# let's just disable compression for these files.
passthru.compressFirmware = false;
} ''
mkdir -p $out/lib/firmware/qcom/x1e80100/LENOVO/83ED
cp ${../firmware}/*.jsn \
$out/lib/firmware/qcom/x1e80100/LENOVO/83ED/
''
{
# The userspace pd-mapper daemon cannot handle zstd compressed firmware, so
# let's just disable compression for these files.
passthru.compressFirmware = false;
}
''
mkdir -p $out/lib/firmware/qcom/x1e80100/LENOVO/83ED
cp ${../firmware}/*.jsn \
$out/lib/firmware/qcom/x1e80100/LENOVO/83ED/
''
6 changes: 5 additions & 1 deletion packages/x1e80100-lenovo-yoga-slim7x-firmware.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
{ fetchFromGitHub, fetchurl, runCommand }:
{
fetchFromGitHub,
fetchurl,
runCommand,
}:

let
# I verified manually that the following files match the SHA256 hashes of ones from my Windows install:
Expand Down
10 changes: 9 additions & 1 deletion packages/x1e80100-linux.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
{ lib, fetchFromGitHub, buildLinux, linuxPackagesFor, fetchpatch, fetchurl, ... }:
{
lib,
fetchFromGitHub,
buildLinux,
linuxPackagesFor,
fetchpatch,
fetchurl,
...
}:

linuxPackagesFor (buildLinux {
src = fetchFromGitHub {
Expand Down

0 comments on commit 00d8bd3

Please sign in to comment.