7 Commits

Author SHA1 Message Date
2574ef4ac0 Merge branch 'master' into fix-51 2025-07-06 05:22:54 +02:00
689c962cc9 fix: necessary code changes for nix configurability 2025-07-06 05:13:09 +02:00
be6e039a9b feat: make a complete nix module 2025-07-06 05:06:54 +02:00
6cac2f91ed fix: neccessary code changes for nix 2025-07-06 04:21:49 +02:00
ee244be195 fix: oopsie path
istg if I keep making these silly mistakes...
2025-07-06 01:54:23 +02:00
b580b6917b feat(nix): reorganize nix flake for modularity and flexibility 2025-07-06 01:24:43 +02:00
22c75a37e1 feat(nix): make flake read version from makefile 2025-07-05 22:28:02 +02:00
12 changed files with 114 additions and 60 deletions

View File

@@ -10,7 +10,9 @@ PREFIX=/usr
CC?=gcc
CFLAGS?=-O3 -Wall
ALLFLAGS=$(CFLAGS) -I$(IDIR)
# C PreProcessor flags, not C Plus Plus
CPPFLAGS?=
ALLFLAGS=$(CFLAGS) $(CPPFLAGS) -I$(IDIR)
LIBS=-lpam

View File

@@ -1,5 +0,0 @@
BAUD_RATE=38400
TERM_NAME=linux
TTY=tty7
EXEC_PATH=/bin/lidm

View File

@@ -1,5 +0,0 @@
#!/bin/sh
[ -r conf ] && . ./conf
exec utmpset -w $TTY

View File

@@ -1,15 +0,0 @@
#!/bin/sh
[ -r conf ] && . ./conf
if [ -x /sbin/getty -o -x /bin/getty ]; then
# busybox
GETTY=getty
elif [ -x /sbin/agetty -o -x /bin/agetty ]; then
# util-linux
GETTY=agetty
fi
exec setsid ${GETTY} ${GETTY_ARGS} \
"${TTY}" "${TERM_NAME}" \
-n -l "${EXEC_PATH}" -o 7

24
assets/pkg/nix/lidm.nix Normal file
View File

@@ -0,0 +1,24 @@
{ config, pkgs, lib, ...}: pkgs.stdenv.mkDerivation rec {
pname = "lidm";
version = config.version;
src = config.src;
nativeBuildInputs = with pkgs; [
gcc
gnumake
linux-pam
];
makeFlags = [
"DESTDIR=$(out)"
"PREFIX="
]
++ lib.optional (config.xsessions != null)
"CPPFLAGS+=-DSESSIONS_XSESSIONS=\\\"${config.xsessions}\\\""
++ lib.optional (config.wayland-sessions != null)
"CPPFLAGS+=-DSESSIONS_WAYLAND=\\\"${config.wayland-sessions}\\\"";
fixupPhase = ''
rm -rf $out/etc
'';
}

47
assets/pkg/nix/module.nix Normal file
View File

@@ -0,0 +1,47 @@
{ config, lib, pkgs, ... }:
let
dmcfg = config.services.displayManager;
desktops = dmcfg.sessionData.desktops;
version = "1.2.1";
lidmPkg = pkgs.callPackage ./lidm.nix {
inherit pkgs;
config = {
inherit version lib;
src = pkgs.fetchFromGitHub {
owner = "javalsai";
repo = "lidm";
rev = "v${version}";
sha256 = "sha256-3CgUI8PUs4c1bfBrykPw87SSa4lzrh4E4Hug7cGRKFk=";
};
xsessions = "${desktops}/share/xsessions";
wayland-sessions = "${desktops}/share/wayland-sessions";
};
};
in
{
config = {
services.displayManager.defaultSession = "lidm";
systemd.services.lidm = {
description = "TUI display manager";
aliases = [ "display-manager.service" ];
after = [
"systemd-user-sessions.service"
"plymouth-quit-wait.service"
];
serviceConfig = {
Type = "idle";
ExecStart = "${lidmPkg}/bin/lidm 7";
StandardInput = "tty";
StandardOutput = "tty";
StandardError = "tty";
TTYPath = "/dev/tty7";
TTYReset = "yes";
TTYVHangup = "yes";
};
};
};
}

View File

@@ -5,9 +5,9 @@ After=systemd-user-sessions.service plymouth-quit-wait.service
[Service]
Type=idle
ExecStart=/usr/bin/lidm 7
StandardError=journal
StandardInput=tty
StandardOutput=tty
StandardError=tty
TTYPath=/dev/tty7
TTYReset=yes
TTYVHangup=yes

View File

@@ -1,8 +1,11 @@
{
description = "A fully colorful customizable TUI display manager made in C for simplicity.";
inputs = {
flake-utils.url = "github:numtide/flake-utils";
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
};
outputs =
{ flake-utils, nixpkgs, ... }:
flake-utils.lib.eachDefaultSystem (
@@ -11,36 +14,27 @@
pkgs = import nixpkgs { inherit system; };
name = "lidm";
version = "0.0.2";
lidm = (
pkgs.stdenv.mkDerivation {
pname = name;
version = version;
version = builtins.elemAt (
builtins.match "VERSION[[:blank:]]*=[[:space:]]*([^\n]*)\n.*" (builtins.readFile ./Makefile)
) 0;
lidm = pkgs.callPackage assets/pkg/nix/lidm.nix {
inherit pkgs;
lib = pkgs.lib;
config = {
inherit version;
src = ./.;
nativeBuildInputs = with pkgs; [
gcc
gnumake
linux-pam
];
makeFlags = [
"DESTDIR=$(out)"
"PREFIX="
];
fixupPhase = ''
rm -rf $out/etc
'';
}
);
xsessions = null;
wayland-sessions = null;
};
};
in
rec {
defaultApp = flake-utils.lib.mkApp { drv = defaultPackage; };
defaultPackage = lidm;
devShell = pkgs.mkShell { buildInputs = lidm.nativeBuildInputs ++ [ pkgs.clang-tools ]; };
}
);
) // {
nixosModules.lidm = assets/pkg/nix/module.nix;
};
}

View File

@@ -1,6 +1,11 @@
#ifndef MACROSH_
#define MACROSH_
// More like constants but I'm not making yet another header file just for this
#ifndef LIDM_CONF_PATH
#define LIDM_CONF_PATH "/etc/lidm.ini"
#endif
// Do we just replace the compiler with clang??
#if defined(__clang__)
#define NULLABLE _Nullable

View File

@@ -12,6 +12,7 @@
#include "config.h"
#include "desktop.h"
#include "log.h"
#include "macros.h"
#include "util.h"
#define UPPER_HALF_BYTE 4
@@ -240,12 +241,10 @@ struct status config_line_handler(void* _config, char* table, char* k,
int parse_config(struct config* NNULLABLE config, char* NNULLABLE path) {
FILE* fd = fopen(path, "r");
if (fd == NULL) {
perror("fopen");
(void)fputs(
"Please place a config file at /etc/lidm.ini or set the LIDM_CONF "
"env variable",
stderr);
return -1;
log_perror("fopen");
log_printf(" [I] No config, place one at " LIDM_CONF_PATH
" or set the LIDM_CONF env variable");
return 0; // Its fine now anyways
}
bool ret = read_desktop(fd, config, config_line_handler);

View File

@@ -72,9 +72,10 @@ int main(int argc, char* argv[]) {
chvt_str(argv[1]);
}
// Copy
struct config config = DEFAULT_CONFIG;
char* conf_override = getenv("LIDM_CONF");
char* conf_path = conf_override ? conf_override : "/etc/lidm.ini";
char* conf_path = conf_override ? conf_override : LIDM_CONF_PATH;
if (parse_config(&config, conf_path) != 0) {
(void)fputs("error parsing config\n", stderr);
return 1;

View File

@@ -16,9 +16,16 @@ struct source_dir {
enum session_type type;
char* dir;
};
#ifndef SESSIONS_XSESSIONS
#define SESSIONS_XSESSIONS "/usr/share/xsessions"
#endif
#ifndef SESSIONS_WAYLAND
#define SESSIONS_WAYLAND "/usr/share/wayland-sessions"
#endif
static const struct source_dir SOURCES[] = {
{XORG, "/usr/share/xsessions"},
{WAYLAND, "/usr/share/wayland-sessions"},
{XORG, SESSIONS_XSESSIONS},
{WAYLAND, SESSIONS_WAYLAND},
};
static struct Vector* cb_sessions = NULL;