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

[WIP] Add Github Actions build job #63

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
f1c6a4f3645f7f03a576a9c4c40119c4eeb138e3
28 changes: 28 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Pull Request
on:
pull_request:
branches:
- main
concurrency:
group: ${{ github.head_ref || github.run_id }}
cancel-in-progress: true
permissions: read-all
jobs:
nix-check:
name: Nix Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: DeterminateSystems/nix-installer-action@main
- uses: DeterminateSystems/magic-nix-cache-action@main
- run: nix flake check
nix-build:
name: Nix Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: DeterminateSystems/nix-installer-action@main
- uses: DeterminateSystems/magic-nix-cache-action@main
- run: |
nix build .#nixosConfigurations.iso.config.system.build.isoImage
sha256sum result/iso/cd.iso
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,3 +178,11 @@ and then use the `x1e-nixos-config.nixosModules.x1e` module.
### Usage without flakes

You should be able to import [`default.nix`](/default.nix) and reference the module as its `nixosModules.x1e` attribute.

## Contributing

### Code formatting

All Nix code in the repository is formatted using [nixfmt](https://github.com/NixOS/nixfmt).

Use the `nix fmt` command to format all files before committing your changes.
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
];
};
};
};
}
23 changes: 22 additions & 1 deletion flake.lock

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

60 changes: 48 additions & 12 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs";
treefmt-nix.url = "github:numtide/treefmt-nix";
treefmt-nix.inputs.nixpkgs.follows = "nixpkgs";
};
outputs = { self, nixpkgs }:
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 @@ -13,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 @@ -29,7 +40,8 @@
allowUnsupportedSystem = true;
};
in
(import ./default.nix) // {
(import ./default.nix)
// {
nixosConfigurations = {
iso = nixpkgs.lib.nixosSystem {
modules = [
Expand All @@ -51,16 +63,40 @@
./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;
}
)
];
};
};
};
}
// (
let
eachSystem = nixpkgs.lib.genAttrs [
"x86_64-linux"
"aarch64-linux"
];
treefmtEval = eachSystem (
system:
(treefmt-nix.lib.evalModule nixpkgs.legacyPackages.${system} {
programs.nixfmt.enable = true;
settings.on-unmatched = "info";
})
);
in
{
formatter = eachSystem (system: treefmtEval.${system}.config.build.wrapper);
checks = eachSystem (system: {
treefmt = treefmtEval.${system}.config.build.check self;
});
}
);
}
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="
];
}
Loading
Loading