From bb82a4d171a58b7194a2bb40cbb4d2dcf0415a94 Mon Sep 17 00:00:00 2001 From: Jonathan Glines Date: Mon, 2 Jun 2014 20:41:35 -0600 Subject: [PATCH 01/10] Added typespeed package. --- pkgs/games/typespeed/builder.sh | 2 ++ pkgs/games/typespeed/default.nix | 12 ++++++++++++ 2 files changed, 14 insertions(+) create mode 100644 pkgs/games/typespeed/builder.sh create mode 100644 pkgs/games/typespeed/default.nix diff --git a/pkgs/games/typespeed/builder.sh b/pkgs/games/typespeed/builder.sh new file mode 100644 index 000000000000..273fc55c7552 --- /dev/null +++ b/pkgs/games/typespeed/builder.sh @@ -0,0 +1,2 @@ +source $stdenv/setup +genericBuild diff --git a/pkgs/games/typespeed/default.nix b/pkgs/games/typespeed/default.nix new file mode 100644 index 000000000000..8acb4de62b46 --- /dev/null +++ b/pkgs/games/typespeed/default.nix @@ -0,0 +1,12 @@ +{ stdenv, fetchurl, ncurses }: + +stdenv.mkDerivation { + name = "typespeed-0.6.5"; + builder = ./builder.sh; + buildInputs = [ ncurses ]; + configureFlags = "--with-highscoredir=/tmp"; + src = fetchurl { + url = http://typespeed.sourceforge.net/typespeed-0.6.5.tar.gz; + sha256 = "5c860385ceed8a60f13217cc0192c4c2b4705c3e80f9866f7d72ff306eb72961"; + }; +} From 833b4276e8fa553fb921c6c91252b7d98ead6375 Mon Sep 17 00:00:00 2001 From: Jonathan Glines Date: Tue, 3 Jun 2014 21:55:32 -0600 Subject: [PATCH 02/10] Working on adding typespeed. --- pkgs/top-level/all-packages.nix | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index e0b35e55d47f..6b0988207f66 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -1599,6 +1599,8 @@ let nilfs_utils = callPackage ../tools/filesystems/nilfs-utils {}; + nitrogen = callPackage ../tools/X11/nitrogen {}; + nlopt = callPackage ../development/libraries/nlopt {}; npapi_sdk = callPackage ../development/libraries/npapi-sdk {}; @@ -10089,6 +10091,8 @@ let trigger = callPackage ../games/trigger { }; + typespeed = callPackage ../games/typespeed { }; + ufoai = callPackage ../games/ufoai { }; ultimatestunts = callPackage ../games/ultimatestunts { }; From 49fe134cb011d66bdfea77579970f23d583911a4 Mon Sep 17 00:00:00 2001 From: Jonathan Glines Date: Tue, 3 Jun 2014 21:56:34 -0600 Subject: [PATCH 03/10] Working on a package for nitrogen. --- pkgs/tools/X11/nitrogen/default.nix | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 pkgs/tools/X11/nitrogen/default.nix diff --git a/pkgs/tools/X11/nitrogen/default.nix b/pkgs/tools/X11/nitrogen/default.nix new file mode 100644 index 000000000000..e9e6587179af --- /dev/null +++ b/pkgs/tools/X11/nitrogen/default.nix @@ -0,0 +1,16 @@ +{ stdenv, fetchurl, pkgconfig }: + +stdenv.mkDerivation rec { + name = "nitrogen-1.5.2"; + + src = fetchurl { + url = "http://projects.l3ib.org/nitrogen/files/nitrogen-1.5.2.tar.gz"; + sha256 = "60a2437ce6a6c0ba44505fc8066c1973140d4bb48e1e5649f525c7b0b8bf9fd2"; + }; + + meta = { + description = "A background browser and setter for X windows"; + homepage = http://projects.l3ib.org/nitrogen/; + platforms = stdenv.lib.platforms.linux; + }; +} From 5a8457d25e5093e0a145db11349272fcdc1cab60 Mon Sep 17 00:00:00 2001 From: Jonathan Glines Date: Sun, 8 Jun 2014 17:37:28 -0600 Subject: [PATCH 04/10] Oops, got nitrogen and typespeed branches mixed up. --- pkgs/tools/X11/nitrogen/default.nix | 16 ---------------- pkgs/top-level/all-packages.nix | 2 -- 2 files changed, 18 deletions(-) delete mode 100644 pkgs/tools/X11/nitrogen/default.nix diff --git a/pkgs/tools/X11/nitrogen/default.nix b/pkgs/tools/X11/nitrogen/default.nix deleted file mode 100644 index e9e6587179af..000000000000 --- a/pkgs/tools/X11/nitrogen/default.nix +++ /dev/null @@ -1,16 +0,0 @@ -{ stdenv, fetchurl, pkgconfig }: - -stdenv.mkDerivation rec { - name = "nitrogen-1.5.2"; - - src = fetchurl { - url = "http://projects.l3ib.org/nitrogen/files/nitrogen-1.5.2.tar.gz"; - sha256 = "60a2437ce6a6c0ba44505fc8066c1973140d4bb48e1e5649f525c7b0b8bf9fd2"; - }; - - meta = { - description = "A background browser and setter for X windows"; - homepage = http://projects.l3ib.org/nitrogen/; - platforms = stdenv.lib.platforms.linux; - }; -} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 7ac66ede5b6e..20864b95628b 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -1609,8 +1609,6 @@ let nilfs_utils = callPackage ../tools/filesystems/nilfs-utils {}; - nitrogen = callPackage ../tools/X11/nitrogen {}; - nlopt = callPackage ../development/libraries/nlopt {}; npapi_sdk = callPackage ../development/libraries/npapi-sdk {}; From 150f6f9ee6734dc9534d022766670b0ee046d952 Mon Sep 17 00:00:00 2001 From: Jonathan Glines Date: Sun, 8 Jun 2014 17:40:16 -0600 Subject: [PATCH 05/10] Removed unneeded builder.sh. --- pkgs/games/typespeed/builder.sh | 2 -- pkgs/games/typespeed/default.nix | 1 - 2 files changed, 3 deletions(-) delete mode 100644 pkgs/games/typespeed/builder.sh diff --git a/pkgs/games/typespeed/builder.sh b/pkgs/games/typespeed/builder.sh deleted file mode 100644 index 273fc55c7552..000000000000 --- a/pkgs/games/typespeed/builder.sh +++ /dev/null @@ -1,2 +0,0 @@ -source $stdenv/setup -genericBuild diff --git a/pkgs/games/typespeed/default.nix b/pkgs/games/typespeed/default.nix index 8acb4de62b46..edb91e164fec 100644 --- a/pkgs/games/typespeed/default.nix +++ b/pkgs/games/typespeed/default.nix @@ -2,7 +2,6 @@ stdenv.mkDerivation { name = "typespeed-0.6.5"; - builder = ./builder.sh; buildInputs = [ ncurses ]; configureFlags = "--with-highscoredir=/tmp"; src = fetchurl { From 54ba3c7ff4855a1e82dc4cede94c9fc5979d8f88 Mon Sep 17 00:00:00 2001 From: Jonathan Glines Date: Sun, 8 Jun 2014 22:44:06 -0600 Subject: [PATCH 06/10] Fixed problem with worddir and ruledir path. --- pkgs/games/typespeed/default.nix | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pkgs/games/typespeed/default.nix b/pkgs/games/typespeed/default.nix index edb91e164fec..1282dec2a8fd 100644 --- a/pkgs/games/typespeed/default.nix +++ b/pkgs/games/typespeed/default.nix @@ -3,9 +3,12 @@ stdenv.mkDerivation { name = "typespeed-0.6.5"; buildInputs = [ ncurses ]; - configureFlags = "--with-highscoredir=/tmp"; src = fetchurl { url = http://typespeed.sourceforge.net/typespeed-0.6.5.tar.gz; sha256 = "5c860385ceed8a60f13217cc0192c4c2b4705c3e80f9866f7d72ff306eb72961"; }; + + patches = [ ./typespeed-config-in-home.patch ]; + + configureFlags = "--datadir=\${out}/share/"; } From 9d04c9021b0b8da15e5a77981721c43886cc9438 Mon Sep 17 00:00:00 2001 From: Jonathan Glines Date: Sun, 8 Jun 2014 22:46:02 -0600 Subject: [PATCH 07/10] Oops, forgot to add patch. --- .../typespeed/typespeed-config-in-home.patch | 159 ++++++++++++++++++ 1 file changed, 159 insertions(+) create mode 100644 pkgs/games/typespeed/typespeed-config-in-home.patch diff --git a/pkgs/games/typespeed/typespeed-config-in-home.patch b/pkgs/games/typespeed/typespeed-config-in-home.patch new file mode 100644 index 000000000000..52d9338775b0 --- /dev/null +++ b/pkgs/games/typespeed/typespeed-config-in-home.patch @@ -0,0 +1,159 @@ +diff --git a/src/file.c b/src/file.c +index d1d1982..dc679a2 100644 +--- a/src/file.c ++++ b/src/file.c +@@ -125,6 +125,8 @@ int hcompar(const void *, const void *); + int loadscores(char *); + static int parseline(char *, char **, char **); + void readconfig(void); ++void mkconfig(char *filename); ++void mkscore(char *filename); + static void readfile(char *, int); + static void setoptions(char *, char *, int); + +@@ -1071,7 +1073,10 @@ parseline(char *line, char **option, char **value) + * let's drop it completely. + */ + if ((p = strchr(line, '\n')) == NULL) ++ { ++ printf("yes, we died here\n"); + return 1; ++ } + *p = '\0'; + if ((p = strchr(line, '\r')) != NULL) + *p = '\0'; +@@ -1125,7 +1130,7 @@ void + readconfig(void) + { + char *envhome; +- char userhigh[MAXPATHLEN], userconf[MAXPATHLEN]; ++ char userhigh[MAXPATHLEN], userconf[MAXPATHLEN], confdir[MAXPATHLEN]; + struct stat sb; + + if (xsnprintf(ruledir, sizeof(ruledir), "%s", RULEDIR)) { +@@ -1140,18 +1145,33 @@ readconfig(void) + readfile(CONFIGFILE, 1); + + if ((envhome = getenv("HOME")) == NULL) +- return; ++ xerr(1, "readconfig: environment variable HOME not set"); + + if (xsnprintf(userconf, sizeof(userconf), "%s/.typespeed/config", +- envhome)) +- return; ++ envhome)) ++ xerr(1, "readconfig: string error"); ++ if (xsnprintf(userhigh, sizeof(userhigh), "%s/.typespeed/score", ++ envhome)) ++ xerr(1, "readconfig: string error"); + + if (stat(userconf, &sb) || (sb.st_mode & S_IFMT) != S_IFREG) +- return; +- +- if (xsnprintf(userhigh, sizeof(userhigh), "%s/.typespeed/score", +- envhome)) +- return; ++ { ++ if (xsnprintf(confdir, sizeof(confdir), "%s/.typespeed", ++ envhome)) ++ xerr(1, "readconfig: string error"); ++ if(stat(confdir, &sb) == -1) ++ if(mkdir(confdir, S_IRWXU | S_IRWXG | S_IRWXO)) ++ xerr(1, "readconfig: could not create config directory %s", ++ confdir); ++ /* create the user configuration with default values */ ++ mkconfig(userconf); ++ } ++ /* check for the high score file */ ++ if (stat(userhigh, &sb) || (sb.st_mode & S_IFMT) != S_IFREG) ++ { ++ /* create a blank high score file */ ++ mkscore(userhigh); ++ } + + /* + * Open a user writable high score. +@@ -1159,14 +1179,48 @@ readconfig(void) + * file. Protect system-wide high score file with group + * write permissions: privileged gid already dropped. + */ +- if (close(hfd) == -1) +- xerr(1, "readconfig: close"); +- if ((hfd = open(userhigh, O_RDWR, 0)) == -1) ++ if ((hfd = open(userhigh, O_RDWR)) == -1) + xerr(1, "readconfig: open: %s", userhigh); + + readfile(userconf, 1); + } + ++#define DEFAULT_CONFIG "cheat = no\n" \ ++ "highorder = score cps tcps\n" \ ++ "ruledir = " RULEDIR "\n" \ ++ "worddir = " WORDDIR "\n" ++ ++/* ++ * Create the user configuration, with default values, at the given path. ++ */ ++void ++mkconfig(char *filename) ++{ ++ int cfd; ++ ++ if((cfd = open(filename, O_WRONLY | O_CREAT, S_IRWXU | S_IRWXG | S_IRWXO)) == -1) ++ xerr(1, "mkconfig: open: %s", filename); ++ if(write(cfd, DEFAULT_CONFIG, sizeof(DEFAULT_CONFIG)/sizeof(DEFAULT_CONFIG[0]) - 1) == -1) ++ xerr(1, "mkconfig: write: %s", filename); ++ if(close(cfd) == -1) ++ xerr(1, "mkconfig: close: %s", filename); ++} ++ ++/* ++ * Create the user high score file, which is just a blank file. ++ */ ++void ++mkscore(char *filename) ++{ ++ int sfd; ++ if((sfd = open(filename, O_WRONLY | O_CREAT, S_IRWXU | S_IRWXG | S_IRWXO)) == -1) ++ xerr(1, "mkscore: open: %s", filename); ++ if(write(sfd, "", 0) == -1) ++ xerr(1, "mkconfig: write: %s", filename); ++ if(close(sfd) == -1) ++ xerr(1, "mkconfig: close: %s", filename); ++} ++ + /* + * Function used to open configuration and game rule files and to + * set options with function setoptions. +diff --git a/src/typespeed.c b/src/typespeed.c +index 7ac5ee2..77e9acb 100644 +--- a/src/typespeed.c ++++ b/src/typespeed.c +@@ -319,8 +319,13 @@ main(int argc, char **argv) + progname++; + + /* just open high score file while being setgid games */ +- if ((hfd = open(HIGHFILE, O_RDWR, 0)) == -1) +- xerr(1, "main: open: %s", HIGHFILE); ++ /* ++ * For NixOS, a global high score file doesn't make sense, so we just comment ++ * this out. A high score file in the user's home directory will be opened ++ * later in readconfig(). ++ */ ++/* if ((hfd = open(HIGHFILE, O_RDWR, 0)) == -1) ++ xerr(1, "main: open: %s", HIGHFILE); */ + + #ifndef WIN32 + /* drop privileges */ +@@ -348,9 +353,9 @@ main(int argc, char **argv) + #endif /* WIN32 */ + + /* check file descriptors for consistency */ +- if (hfd == STDIN_FILENO || hfd == STDOUT_FILENO || ++/* if (hfd == STDIN_FILENO || hfd == STDOUT_FILENO || + hfd == STDERR_FILENO) +- exit(1); ++ exit(1); */ + if (!isatty(STDIN_FILENO) || !isatty(STDOUT_FILENO) || + !isatty(STDERR_FILENO)) + xerrx(1, "not fully connected to a terminal"); From 0806afad5a8466653cb8fb9b304d9faf5d143f91 Mon Sep 17 00:00:00 2001 From: Jonathan Glines Date: Sun, 8 Jun 2014 23:19:06 -0600 Subject: [PATCH 08/10] Added metadata for typespeed. --- pkgs/games/typespeed/default.nix | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pkgs/games/typespeed/default.nix b/pkgs/games/typespeed/default.nix index 1282dec2a8fd..57fd8f7dfc52 100644 --- a/pkgs/games/typespeed/default.nix +++ b/pkgs/games/typespeed/default.nix @@ -11,4 +11,10 @@ stdenv.mkDerivation { patches = [ ./typespeed-config-in-home.patch ]; configureFlags = "--datadir=\${out}/share/"; + + meta = { + description = "A curses based typing game."; + homepage = http://typespeed.sourceforge.net/; + license = "GLPv2"; + }; } From b690f36d6f92c47303b80f9c887ac79923be4f1c Mon Sep 17 00:00:00 2001 From: Jonathan Glines Date: Sun, 8 Jun 2014 23:43:28 -0600 Subject: [PATCH 09/10] Oops, removed a printf debug line we don't need. --- pkgs/games/typespeed/default.nix | 2 +- .../typespeed/typespeed-config-in-home.patch | 19 ++++--------------- 2 files changed, 5 insertions(+), 16 deletions(-) diff --git a/pkgs/games/typespeed/default.nix b/pkgs/games/typespeed/default.nix index 57fd8f7dfc52..24ace16adc7a 100644 --- a/pkgs/games/typespeed/default.nix +++ b/pkgs/games/typespeed/default.nix @@ -15,6 +15,6 @@ stdenv.mkDerivation { meta = { description = "A curses based typing game."; homepage = http://typespeed.sourceforge.net/; - license = "GLPv2"; + license = "GPLv2"; }; } diff --git a/pkgs/games/typespeed/typespeed-config-in-home.patch b/pkgs/games/typespeed/typespeed-config-in-home.patch index 52d9338775b0..fe313a4392ed 100644 --- a/pkgs/games/typespeed/typespeed-config-in-home.patch +++ b/pkgs/games/typespeed/typespeed-config-in-home.patch @@ -1,5 +1,5 @@ diff --git a/src/file.c b/src/file.c -index d1d1982..dc679a2 100644 +index d1d1982..1655f6f 100644 --- a/src/file.c +++ b/src/file.c @@ -125,6 +125,8 @@ int hcompar(const void *, const void *); @@ -11,18 +11,7 @@ index d1d1982..dc679a2 100644 static void readfile(char *, int); static void setoptions(char *, char *, int); -@@ -1071,7 +1073,10 @@ parseline(char *line, char **option, char **value) - * let's drop it completely. - */ - if ((p = strchr(line, '\n')) == NULL) -+ { -+ printf("yes, we died here\n"); - return 1; -+ } - *p = '\0'; - if ((p = strchr(line, '\r')) != NULL) - *p = '\0'; -@@ -1125,7 +1130,7 @@ void +@@ -1125,7 +1127,7 @@ void readconfig(void) { char *envhome; @@ -31,7 +20,7 @@ index d1d1982..dc679a2 100644 struct stat sb; if (xsnprintf(ruledir, sizeof(ruledir), "%s", RULEDIR)) { -@@ -1140,18 +1145,33 @@ readconfig(void) +@@ -1140,18 +1142,33 @@ readconfig(void) readfile(CONFIGFILE, 1); if ((envhome = getenv("HOME")) == NULL) @@ -73,7 +62,7 @@ index d1d1982..dc679a2 100644 /* * Open a user writable high score. -@@ -1159,14 +1179,48 @@ readconfig(void) +@@ -1159,14 +1176,48 @@ readconfig(void) * file. Protect system-wide high score file with group * write permissions: privileged gid already dropped. */ From 8e2556bd7fcc77583ded78e8e2d4db65cbf9f414 Mon Sep 17 00:00:00 2001 From: Jonathan Glines Date: Sun, 8 Jun 2014 23:47:59 -0600 Subject: [PATCH 10/10] Added auntie as a maintainer, and set license properly. --- lib/maintainers.nix | 1 + pkgs/games/typespeed/default.nix | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/maintainers.nix b/lib/maintainers.nix index 8a98cb146513..a0aae2f3b592 100644 --- a/lib/maintainers.nix +++ b/lib/maintainers.nix @@ -17,6 +17,7 @@ arobyn = "Alexei Robyn "; astsmtl = "Alexander Tsamutali "; aszlig = "aszlig "; + auntie = "Jonathan Glines "; bbenoist = "Baptist BENOIST "; bennofs = "Benno Fünfstück "; berdario = "Dario Bertini "; diff --git a/pkgs/games/typespeed/default.nix b/pkgs/games/typespeed/default.nix index 24ace16adc7a..169c74621d73 100644 --- a/pkgs/games/typespeed/default.nix +++ b/pkgs/games/typespeed/default.nix @@ -15,6 +15,7 @@ stdenv.mkDerivation { meta = { description = "A curses based typing game."; homepage = http://typespeed.sourceforge.net/; - license = "GPLv2"; + license = stdenv.lib.licenses.gpl2; + maintainers = [ stdenv.lib.maintainers.auntie ]; }; }