Skip to content
This repository has been archived by the owner on Sep 27, 2024. It is now read-only.

Commit

Permalink
feat: use flake gen
Browse files Browse the repository at this point in the history
  • Loading branch information
RossComputerGuy committed May 31, 2024
1 parent 65d1c38 commit 455874c
Show file tree
Hide file tree
Showing 2 changed files with 129 additions and 131 deletions.
117 changes: 102 additions & 15 deletions flake.lock

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

143 changes: 27 additions & 116 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -1,84 +1,35 @@
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
nixos-hardware.url = "github:NixOS/nixos-hardware";
nixos-mobile = {
url = "github:RossComputerGuy/mobile-nixos/fix/impure";
flake = false;
};
expidus.url = "github:ExpidusOS/expidus";
nixos-apple-silicon.url = "github:tpwrules/nixos-apple-silicon/1b16e4290a5e4a59c75ef53617d597e02078791e";
flake-utils.url = "github:numtide/flake-utils";
};

outputs = {
self,
nixpkgs,
nixos-hardware,
nixos-mobile,
expidus,
nixos-apple-silicon,
flake-utils,
...
}@inputs:
(flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs { inherit system; };
inherit (pkgs) lib;

isAsahi = pkgs.targetPlatform.isAarch64 && pkgs.stdenv.isLinux;

overlay = f: s: {
expidus = s.expidus // {
genesis-shell = s.flutter.buildFlutterApplication {
pname = "genesis-shell";
version = "0-unstable-git+${self.shortRev or "dirty"}";

src = lib.cleanSource self;

buildInputs = with s; lib.optionalAttrs (stdenv.isLinux) [
pam accountsservice polkit seatd wlroots_0_17 libdrm libGL libxkbcommon
mesa vulkan-loader libdisplay-info libliftoff libinput xorg.xcbutilwm
xorg.libX11 xorg.xcbutilerrors xorg.xcbutilimage xorg.xcbutilrenderutil
libepoxy
];

pubspecLock = lib.importJSON ./pubspec.lock.json;

gitHashes = {
libtokyo = "sha256-Zn30UmppXnzhs+t+EQNwAhaTPjCCxoN0a+AbH6bietg=";
libtokyo_flutter = "sha256-Zn30UmppXnzhs+t+EQNwAhaTPjCCxoN0a+AbH6bietg=";
};

postInstall = ''
mv $out/bin/genesis_shell $out/bin/genesis-shell
'';

meta = {
mainProgram = "genesis-shell";
};
expidus.lib.mkFlake {
overlay = final: prev: {
expidus = prev.expidus // {
genesis-shell = prev.expidus.genesis-shell.overrideAttrs (f: p: {
version = "0-unstable-git+${self.shortRev or "dirty"}";
src = prev.lib.cleanSource self;

pubspecLock = prev.lib.importJSON ./pubspec.lock.json;

gitHashes = {
libtokyo = "sha256-Zn30UmppXnzhs+t+EQNwAhaTPjCCxoN0a+AbH6bietg=";
libtokyo_flutter = "sha256-Zn30UmppXnzhs+t+EQNwAhaTPjCCxoN0a+AbH6bietg=";
};
};
};
in {
packages = {
default = self.legacyPackages.${system}.expidus.genesis-shell;
} // lib.optionalAttrs (isAsahi) {
asahi = self.legacyPackages.${system}.pkgsAsahi.expidus.genesis-shell;
});
};
};

legacyPackages = pkgs.appendOverlays (lib.optionals (isAsahi) [
(f: p: {
pkgsAsahi = p.appendOverlays [
nixos-apple-silicon.overlays.default
(f: p: {
mesa = p.mesa-asahi-edge;
})
];
})
] ++ [
overlay
]);

devShells = let
mkShells = self:
let
inherit (self.legacyPackages) lib;
mkShell = pkgs: pkg: pkgs.mkShell {
inherit (pkg) pname version name;
inputsFrom = [ pkg ];
Expand All @@ -88,56 +39,16 @@
mesa-demos
];
};

pkgs = self.legacyPackages.${system};
in {
default = mkShell pkgs self.packages.${system}.default;
} // lib.optionalAttrs (isAsahi) {
asahi = mkShell pkgs.pkgsAsahi self.packages.${system}.asahi;
default = mkShell self.legacyPackages self.packages.default;
} // lib.optionalAttrs (self.legacyPackages.isAsahi) {
asahi = mkShell self.legacyPackages.pkgsAsahi self.packages.asahi;
};
})) // {
nixosConfigurations = let
mkSystem = modules: system:
let
pkgs = self.legacyPackages.${system};
inherit (nixpkgs) lib;
in lib.nixosSystem {
inherit system lib pkgs;

modules = modules ++ [
./nix/module.nix
];
};

mkMobileSystem = device: system:
let
pkgs = self.legacyPackages.${system};
inherit (nixpkgs) lib;
in import "${nixos-mobile}" {
inherit system pkgs device;
configuration = { config, lib, ... }: {
imports = [ ./nix/module.nix ];

config = lib.mkIf (device == "pine64-pinephone") {
services.cage.environment.LIBGL_ALWAYS_SOFTWARE = "1";
};
};
};

mkQemu = system: mkSystem [
"${nixpkgs}/nixos/modules/virtualisation/qemu-vm.nix"
{
config = {
system.name = "qemu-${self.legacyPackages.${system}.targetPlatform.qemuArch}";
boot.kernelParams = nixpkgs.lib.mkAfter [ "console=ttyS0" ];
};
}
] system;
in {
qemu-aarch64 = mkQemu "aarch64-linux";
qemu-x86_64 = mkQemu "x86_64-linux";

pine64-pinephone = mkMobileSystem "pine64-pinephone" "aarch64-linux";
};
mkPackages = self: {
default = self.legacyPackages.expidus.genesis-shell;
} // self.legacyPackages.lib.optionalAttrs (self.legacyPackages.isAsahi) {
asahi = self.legacyPackages.pkgsAsahi.expidus.genesis-shell;
};
};
}

0 comments on commit 455874c

Please sign in to comment.