Setup a very basic development env

This commit is contained in:
Sameer Rahmani 2024-02-02 22:57:50 +00:00
parent f6621bd6bd
commit 0e9789cca5
Signed by: lxsameer
GPG Key ID: B0A4AF28AB9FD90B
6 changed files with 325 additions and 0 deletions

1
.gitignore vendored
View File

@ -16,3 +16,4 @@ result-*
# Undo-tree save-files
*.~undo-tree
vdisk1

180
flake.lock Normal file
View File

@ -0,0 +1,180 @@
{
"nodes": {
"agenix": {
"inputs": {
"darwin": "darwin",
"home-manager": "home-manager",
"nixpkgs": [
"nixpkgs"
],
"systems": "systems"
},
"locked": {
"lastModified": 1703433843,
"narHash": "sha256-nmtA4KqFboWxxoOAA6Y1okHbZh+HsXaMPFkYHsoDRDw=",
"owner": "ryantm",
"repo": "agenix",
"rev": "417caa847f9383e111d1397039c9d4337d024bf0",
"type": "github"
},
"original": {
"owner": "ryantm",
"repo": "agenix",
"type": "github"
}
},
"darwin": {
"inputs": {
"nixpkgs": [
"agenix",
"nixpkgs"
]
},
"locked": {
"lastModified": 1700795494,
"narHash": "sha256-gzGLZSiOhf155FW7262kdHo2YDeugp3VuIFb4/GGng0=",
"owner": "lnl7",
"repo": "nix-darwin",
"rev": "4b9b83d5a92e8c1fbfd8eb27eda375908c11ec4d",
"type": "github"
},
"original": {
"owner": "lnl7",
"ref": "master",
"repo": "nix-darwin",
"type": "github"
}
},
"home-manager": {
"inputs": {
"nixpkgs": [
"agenix",
"nixpkgs"
]
},
"locked": {
"lastModified": 1703113217,
"narHash": "sha256-7ulcXOk63TIT2lVDSExj7XzFx09LpdSAPtvgtM7yQPE=",
"owner": "nix-community",
"repo": "home-manager",
"rev": "3bfaacf46133c037bb356193bd2f1765d9dc82c1",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "home-manager",
"type": "github"
}
},
"home-manager_2": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1706798041,
"narHash": "sha256-BbvuF4CsVRBGRP8P+R+JUilojk0M60D7hzqE0bEvJBQ=",
"owner": "nix-community",
"repo": "home-manager",
"rev": "4d53427bce7bf3d17e699252fd84dc7468afc46e",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "home-manager",
"type": "github"
}
},
"nixos-hardware": {
"locked": {
"lastModified": 1706834982,
"narHash": "sha256-3CfxA7gZ+DVv/N9Pvw61bV5Oe/mWfxYPyVQGqp9TMJA=",
"owner": "nixos",
"repo": "nixos-hardware",
"rev": "83e571bb291161682b9c3ccd48318f115143a550",
"type": "github"
},
"original": {
"owner": "nixos",
"repo": "nixos-hardware",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1706732774,
"narHash": "sha256-hqJlyJk4MRpcItGYMF+3uHe8HvxNETWvlGtLuVpqLU0=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "b8b232ae7b8b144397fdb12d20f592e5e7c1a64d",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"agenix": "agenix",
"home-manager": "home-manager_2",
"nixos-hardware": "nixos-hardware",
"nixpkgs": "nixpkgs",
"utils": "utils"
}
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
},
"systems_2": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
},
"utils": {
"inputs": {
"systems": "systems_2"
},
"locked": {
"lastModified": 1705309234,
"narHash": "sha256-uNRRNRKmJyCRC/8y1RqBkqWBLM034y4qN7EprSdmgyA=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "1ef2e671c3b0c19053962c07dbda38332dcebf26",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
}
},
"root": "root",
"version": 7
}

95
flake.nix Normal file
View File

@ -0,0 +1,95 @@
{
description = "lxsameer's universe";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
nixos-hardware.url = "github:nixos/nixos-hardware";
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, home-manager, nixpkgs, agenix, nixos-hardware, 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
'';
scripts = pkgs.symlinkJoin {
name = "universe_scripts";
paths = [
create-disk
];
};
nativeBuildInputs = with pkgs; [
qemu
fish
zstd
scripts
];
in rec{
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 = images.majin;
nixosConfigurations = {
majin = pkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [
"${pkgs}/nixos/modules/profiles/minimal.nix"
./worlds/majin/configuration.nix
home-manager.nixosModules.home-manager
agenix.nixosModules.age
./worlds/base.nix
#hercules-ci-agent.nixosModules.multi-agent-service
];
specialArgs = { inherit inputs; };
};
};
devShells.${system}.default = pkgs.mkShell {
inherit nativeBuildInputs;
shellHook = ''
fish && exit
'';
};
};
}

26
worlds/base.nix Normal file
View File

@ -0,0 +1,26 @@
{ pkgs, config, lib, ... }:
{
# This causes an overlay which causes a lot of rebuilding
environment.noXlibs = lib.mkForce false;
# "${nixpkgs}/nixos/modules/installer/sd-card/sd-image-aarch64.nix" creates a
# disk with this label on first boot. Therefore, we need to keep it. It is the
# only information from the installer image that we need to keep persistent
fileSystems."/" =
{ device = "/dev/disk/by-label/NIXOS_SD";
fsType = "ext4";
};
boot = {
kernelPackages = lib.mkForce pkgs.linuxPackages_latest;
loader = {
generic-extlinux-compatible.enable = lib.mkDefault true;
grub.enable = lib.mkDefault false;
};
};
nix.settings = {
experimental-features = lib.mkDefault "nix-command flakes";
trusted-users = [ "root" "@wheel" "lxsameer" ];
};
}

View File

@ -0,0 +1,23 @@
{ pkgs, config, lib, ... }:
{
environment.systemPackages = with pkgs; [ emacs git ];
services.openssh.enable = true;
networking.hostName = "majin";
users = {
users.lxsameer = {
password = "123123";
isNormalUser = true;
extraGroups = [ "wheel" ];
};
};
# networking = {
# interfaces."wlan0".useDHCP = true;
# wireless = {
# interfaces = [ "wlan0" ];
# enable = true;
# networks = {
# networkSSID.psk = "password";
# };
# };
# };
}

View File