133 lines
3.7 KiB
Nix
133 lines
3.7 KiB
Nix
# Universe - The big bang to my universe
|
|
#
|
|
# Copyright (c) 2023-2024 Sameer Rahmani <lxsameer@gnu.org>
|
|
#
|
|
# This program is free software; you can redistribute it and/or modify
|
|
# it under the terms of the GNU General Public License as published by
|
|
# the Free Software Foundation, version 2.
|
|
#
|
|
# This program is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU General Public License
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
{
|
|
description = "lxsameer's universe";
|
|
|
|
inputs = {
|
|
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
|
|
sops-nix = {
|
|
url = "github:Mic92/sops-nix";
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
};
|
|
|
|
nixos-hardware.url = "github:nixos/nixos-hardware";
|
|
nixos-generators = {
|
|
url = "github:nix-community/nixos-generators";
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
};
|
|
home-manager = {
|
|
url = "github:nix-community/home-manager";
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
};
|
|
|
|
agenix = {
|
|
url = "github:ryantm/agenix";
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
};
|
|
|
|
utils.url = "github:numtide/flake-utils";
|
|
|
|
# TODO: Checkout hercules
|
|
# hercules-ci-agent.url = "github:hercules-ci/hercules-ci-agent";
|
|
# To build and android image
|
|
# robotnix.url = "github:danielfullmer/robotnix";
|
|
# impermanence.url = "github:nix-community/impermanence";
|
|
};
|
|
|
|
outputs = { self, nixpkgs, utils, ... } @ inputs:
|
|
let
|
|
# I just use linux and currently only x86_64
|
|
system = "x86_64-linux";
|
|
pkgs = import nixpkgs { inherit system; };
|
|
|
|
# Add a command to the shell to create the disk
|
|
create-disk = pkgs.writeScriptBin "create-disk" ''
|
|
#!${pkgs.stdenv.shell}
|
|
|
|
qemu-img create -f qcow2 vdisk1 10G
|
|
'';
|
|
|
|
bootImage = image: (pkgs.writeScriptBin "boot-${image.name}" ''
|
|
#!${pkgs.stdenv.shell}
|
|
|
|
qemu-system-x86_64 -enable-kvm -m 2048 -boot d \
|
|
-cdrom ${image} -hda vdisk1 -vga std \
|
|
-net user,hostfwd=tcp::2222-:22 -net nic
|
|
'');
|
|
|
|
scripts = pkgs.symlinkJoin {
|
|
name = "universe_scripts";
|
|
paths = [
|
|
create-disk
|
|
];
|
|
};
|
|
|
|
nativeBuildInputs = with pkgs; [
|
|
qemu
|
|
fish
|
|
zstd
|
|
scripts
|
|
sops
|
|
];
|
|
|
|
modules = pkgs.callPackage ./modules { inherit (inputs) nixos-generators; };
|
|
|
|
in rec{
|
|
inherit pkgs;
|
|
|
|
images = {
|
|
majin = (nixosConfigurations.majin.extendModules {
|
|
modules = [
|
|
"${pkgs}/nixos/modules/installer/sd-card/sd-image-x86_64.nix"
|
|
{
|
|
disabledModules = [ "profiles/base.nix" ];
|
|
}
|
|
];
|
|
}).config.system.build.sdImage;
|
|
};
|
|
|
|
packages.${system} = {
|
|
majin = nixosConfigurations.majin.config.formats.iso;
|
|
boot-majin = bootImage packages.${system}.majin;
|
|
inherit create-disk;
|
|
};
|
|
|
|
|
|
nixosConfigurations = {
|
|
majin = nixpkgs.lib.nixosSystem {
|
|
system = "x86_64-linux";
|
|
modules = [
|
|
"${nixpkgs}/nixos/modules/profiles/minimal.nix"
|
|
./worlds/majin/configuration.nix
|
|
modules.generator
|
|
inputs.home-manager.nixosModules.home-manager
|
|
./worlds/base.nix
|
|
#hercules-ci-agent.nixosModules.multi-agent-service
|
|
];
|
|
specialArgs = { inherit inputs; };
|
|
};
|
|
};
|
|
|
|
devShells.${system}.default = pkgs.mkShell {
|
|
inherit nativeBuildInputs;
|
|
shellHook = ''
|
|
fish && exit
|
|
'';
|
|
};
|
|
|
|
};
|
|
}
|